commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1156278 - /commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
Date Wed, 10 Aug 2011 17:59:37 GMT
Author: tv
Date: Wed Aug 10 17:59:37 2011
New Revision: 1156278

URL: http://svn.apache.org/viewvc?rev=1156278&view=rev
Log:
Make sure lock is released (reported by FindBugs)

Modified:
    commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java?rev=1156278&r1=1156277&r2=1156278&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/AbstractDiskCache.java
Wed Aug 10 17:59:37 2011
@@ -143,9 +143,23 @@ public abstract class AbstractDiskCache
         // removeall
         removeAllLock.writeLock().lock();
 
-        if ( purgatory != null )
+        try
         {
-            synchronized ( purgatory )
+            if ( purgatory != null )
+            {
+                synchronized ( purgatory )
+                {
+                    if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
+                    {
+                        purgatory = new LRUMapJCS<Serializable, PurgatoryElement>(
diskCacheAttributes.getMaxPurgatorySize() );
+                    }
+                    else
+                    {
+                        purgatory = new HashMap<Serializable, PurgatoryElement>();
+                    }
+                }
+            }
+            else
             {
                 if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
                 {
@@ -157,19 +171,10 @@ public abstract class AbstractDiskCache
                 }
             }
         }
-        else
+        finally
         {
-            if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
-            {
-                purgatory = new LRUMapJCS<Serializable, PurgatoryElement>( diskCacheAttributes.getMaxPurgatorySize()
);
-            }
-            else
-            {
-                purgatory = new HashMap<Serializable, PurgatoryElement>();
-            }
+            removeAllLock.writeLock().unlock();
         }
-
-        removeAllLock.writeLock().unlock();
     }
 
     // ------------------------------------------------------- interface ICache



Mime
View raw message