felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1656672 - /felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
Date Tue, 03 Feb 2015 10:48:40 GMT
Author: gnodet
Date: Tue Feb  3 10:48:40 2015
New Revision: 1656672

URL: http://svn.apache.org/r1656672
Log:
[FELIX-4783] ConcurrentModificationException when stopping gogo

Modified:
    felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java

Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java?rev=1656672&r1=1656671&r2=1656672&view=diff
==============================================================================
--- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
(original)
+++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java
Tue Feb  3 10:48:40 2015
@@ -72,10 +72,7 @@ public class CommandProcessorImpl implem
     {
         synchronized (sessions)
         {
-            if (sessions.remove(session) != null)
-            {
-                System.out.println("CLOSED: " + session);
-            }
+            sessions.remove(session);
         }
     }
 
@@ -84,10 +81,13 @@ public class CommandProcessorImpl implem
         synchronized (sessions)
         {
             stopped = true;
-            for (CommandSession session : sessions.keySet())
+            // Create a copy, as calling session.close() will remove the session from the
map
+            CommandSession[] toClose = this.sessions.keySet().toArray(new CommandSession[this.sessions.size()]);
+            for (CommandSession session : toClose)
             {
                 session.close();
             }
+            // Just in case...
 			sessions.clear();
         }
     }



Mime
View raw message