1. opensymphony
  2. oscache

Commits

chri...@81dbac14-341a-0410-aa85-cbcd92e6f43e  committed b5f7807

[CACHE-73] Allow the barrier lock to be reconstructed when this class is deserialized.

  • Participants
  • Parent commits 2e6c9a3
  • Branches default

Comments (0)

Files changed (1)

File src/core/java/com/opensymphony/oscache/base/algorithm/AbstractConcurrentReadCache.java

View file
  • Ignore whitespace
     /**
      * Lock used only for its memory effects.
      **/
-    protected final transient Object barrierLock = new Object();
+    protected transient Object barrierLock = new Object();
 
     /**
      * field written to only to guarantee lock ordering.
      * instance from a stream (i.e.,
      * deserialize it).
      */
-    protected synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
+    private synchronized void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
         // Read in the threshold, loadfactor, and any hidden stuff
         s.defaultReadObject();
 
+        barrierLock = new Object();
+
         // Read in number of buckets and allocate the bucket array;
         int numBuckets = s.readInt();
         table = new Entry[numBuckets];
      * for each key-value mapping represented by the AbstractConcurrentReadCache
      * The key-value mappings are emitted in no particular order.
      */
-    protected synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException {
+    private synchronized void writeObject(java.io.ObjectOutputStream s) throws IOException {
         // Write out the threshold, loadfactor, and any hidden stuff
         s.defaultWriteObject();