jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r438504 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java
Date Wed, 30 Aug 2006 14:45:14 GMT
Author: stefan
Date: Wed Aug 30 07:45:14 2006
New Revision: 438504

URL: http://svn.apache.org/viewvc?rev=438504&view=rev
Log:
JCR-549: TransientFileFactory may throw ConcurrentModificationException on shutdown

Modified:
    jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java?rev=438504&r1=438503&r2=438504&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/util/TransientFileFactory.java
Wed Aug 30 07:45:14 2006
@@ -82,9 +82,15 @@
         // register shutdownhook for final cleaning up
         Runtime.getRuntime().addShutdownHook(new Thread() {
             public void run() {
-                for (Iterator it = trackedRefs.iterator(); it.hasNext();) {
-                    MoribundFileReference fileRef = (MoribundFileReference) it.next();
-                    fileRef.delete();
+                // synchronize on the list before iterating over it in order
+                // to avoid ConcurrentModificationException (JCR-549)
+                // @see java.lang.util.Collections.synchronizedList(java.util.List)
+                synchronized(trackedRefs) {
+                    for (Iterator it = trackedRefs.iterator(); it.hasNext();) {
+                        MoribundFileReference fileRef = (MoribundFileReference) it.next();
+                        fileRef.delete();
+                    }
+
                 }
             }
         });



Mime
View raw message