• Bug
  • Status: Closed
  • 1 Critical
  • Resolution: Fixed
  • ehcache-core
  • hsingh
  • Reporter: amiller
  • October 27, 2009
  • 0
  • Watchers: 0
  • January 17, 2013
  • November 03, 2009

Description

Many fields in core classes are read and written by multiple threads but don’t properly use either synchronized or volatile. These fields are subject to visibility issues due to the Java Memory Model and should be made volatile or read/written under synchronization.

Element fields:

  • version - read/written w/o synchronization. at least make volatile. only written outside constructor in tests? change tests and remove setter?
  • hitCount - long read/written w/o synchronization - visibility and long-tearing issues. use AtomicLong.
  • timeToLive - read/written w/o synchronization. make volatile.
  • timeToIdle - read/written w/o synchronization. make volatile.
  • elementEvictionData - ok, volatile transient
  • lastUpdateTime - read/written w/o synchronization. make volatile.

Comments