jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r519892 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
Date Mon, 19 Mar 2007 10:03:50 GMT
Author: stefan
Date: Mon Mar 19 03:03:49 2007
New Revision: 519892

URL: http://svn.apache.org/viewvc?view=rev&rev=519892
Log:
JCR-798: ConcurrentModificationException during logout

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

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java?view=diff&rev=519892&r1=519891&r2=519892
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/state/LocalItemStateManager.java
Mon Mar 19 03:03:49 2007
@@ -335,13 +335,20 @@
 
         // this LocalItemStateManager instance is no longer needed;
         // cached item states can now be safely discarded
-        Iterator iter = cache.values().iterator();
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
-            dispatcher.notifyStateDiscarded(state);
-            // let the item state know that it has been disposed
-            state.onDisposed();
+
+        // JCR-798: copy cached item states to array
+        // to avoid ConcurrentModificationException
+        ItemState[] isa = (ItemState[]) cache.values().toArray(
+                new ItemState[cache.size()]);
+        for (int i = 0; i < isa.length; i++) {
+            ItemState state = isa[i];
+            if (state != null) {
+                dispatcher.notifyStateDiscarded(state);
+                // let the item state know that it has been disposed
+                state.onDisposed();
+            }
         }
+
         // clear cache
         cache.evictAll();
         cache.dispose();



Mime
View raw message