jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r330018 - /incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java
Date Tue, 01 Nov 2005 10:32:14 GMT
Author: stefan
Date: Tue Nov  1 02:32:10 2005
New Revision: 330018

URL: http://svn.apache.org/viewcvs?rev=330018&view=rev
Log:
fixed potential ConcurrentModificationException in RepositoryImpl.shutdown()

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=330018&r1=330017&r2=330018&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/RepositoryImpl.java Tue
Nov  1 02:32:10 2005
@@ -705,10 +705,7 @@
     }
 
     /**
-     * Shuts down this repository. Note that this method is called automatically
-     * through a shutdown hook.
-     *
-     * @see Runtime#addShutdownHook(Thread)
+     * Shuts down this repository.
      */
     public synchronized void shutdown() {
         // check status of this instance
@@ -718,10 +715,17 @@
         }
 
         // close active user sessions
-        for (Iterator it = activeSessions.values().iterator(); it.hasNext();) {
-            SessionImpl session = (SessionImpl) it.next();
-            session.removeListener(this);
-            session.logout();
+        // (copy sessions to array to avoid ConcurrentModificationException)
+        int cnt = 0;
+        SessionImpl[] sa = new SessionImpl[activeSessions.size()];
+        for (Iterator it = activeSessions.values().iterator(); it.hasNext(); cnt++) {
+            sa[cnt] = (SessionImpl) it.next();
+        }
+        for (int i = 0; i < sa.length; i++) {
+            if (sa[i] != null) {
+                sa[i].removeListener(this);
+                sa[i].logout();
+            }
         }
         activeSessions.clear();
 



Mime
View raw message