jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r475735 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
Date Thu, 16 Nov 2006 13:48:24 GMT
Author: stefan
Date: Thu Nov 16 05:48:23 2006
New Revision: 475735

URL: http://svn.apache.org/viewvc?view=rev&rev=475735
Log:
JCR-619: CacheManager (Memory Management in Jackrabbit)

applied patch that fixes dead lock issue

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java?view=diff&rev=475735&r1=475734&r2=475735
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/state/CacheManager.java
Thu Nov 16 05:48:23 2006
@@ -87,14 +87,16 @@
      * Re-calcualte the maximum memory for each cache, and set the new limits.
      */
     private void resizeAll() {
-        log.info("resizeAll size="+ caches.size());
+        log.info("resizeAll size=" + caches.size());
         // get strong references
         // entries in a weak hash map may disappear any time
         // so can't use size() / keySet() directly
         // only using the iterator guarantees that we don't get null references
         ArrayList list = new ArrayList();
-        for (Iterator it = caches.keySet().iterator(); it.hasNext();) {
-            list.add(it.next());
+        synchronized (caches) {
+            for (Iterator it = caches.keySet().iterator(); it.hasNext();) {
+                list.add(it.next());
+            }
         }
         if (list.size() == 0) {
             // nothing to do
@@ -167,8 +169,10 @@
      *
      * @param cache the cache to add
      */
-    public synchronized void add(Cache cache) {
-        caches.put(cache, null);
+    public void add(Cache cache) {
+        synchronized (caches) {
+            caches.put(cache, null);
+        }
     }
 
     /**
@@ -179,8 +183,10 @@
      * @param cache
      *            the cache to remove
      */
-    public synchronized void remove(Cache cache) {
-        caches.remove(cache);
+    public void remove(Cache cache) {
+        synchronized (caches) {
+            caches.remove(cache);
+        }
     }
 
     /**



Mime
View raw message