jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject svn commit: r389129 - /jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Date Mon, 27 Mar 2006 12:55:39 GMT
Author: stefan
Date: Mon Mar 27 04:55:36 2006
New Revision: 389129

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

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

Modified: jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java?rev=389129&r1=389128&r2=389129&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit/src/main/java/org/apache/jackrabbit/core/RepositoryImpl.java
Mon Mar 27 04:55:36 2006
@@ -843,9 +843,19 @@
         log.info("Shutting down repository...");
 
         // close active user sessions
-        while (!activeSessions.isEmpty()) {
-           ((Session) activeSessions.values().iterator().next()).logout();
-       }
+        // (copy sessions to array to avoid ConcurrentModificationException;
+        // manually copy entries rather than calling ReferenceMap#toArray() in
+        // order to work around  http://issues.apache.org/bugzilla/show_bug.cgi?id=25551)
+        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].logout();
+            }
+        }
 
         // shut down workspaces
         for (Iterator it = wspInfos.values().iterator(); it.hasNext();) {



Mime
View raw message