Author: ron.sigal(a)jboss.com
Date: 2009-04-13 06:29:47 -0400 (Mon, 13 Apr 2009)
New Revision: 4983
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionNotifier.java
Log:
JBREM-1113: Use copies of lists to avoid ConcurrentModificationException.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionNotifier.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionNotifier.java 2009-04-13
06:49:46 UTC (rev 4982)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionNotifier.java 2009-04-13
10:29:47 UTC (rev 4983)
@@ -47,14 +47,17 @@
Client client = new Client(new InvokerLocator(locatorurl), requestPayload);
client.setSessionId(clientSessionId);
+ ArrayList localListeners = null;
synchronized (listeners)
{
- Iterator it = listeners.iterator();
- while (it.hasNext())
- {
- ((ConnectionListener) it.next()).handleConnectionException(null, client);
- }
+ localListeners = new ArrayList(listeners);
}
+
+ Iterator it = localListeners.iterator();
+ while (it.hasNext())
+ {
+ ((ConnectionListener) it.next()).handleConnectionException(null, client);
+ }
}
catch(Exception e)
{
@@ -74,14 +77,17 @@
client.setSessionId(clientSessionId);
ClientDisconnectedException ex = new ClientDisconnectedException();
+ ArrayList localListeners = null;
synchronized (listeners)
{
- Iterator it = listeners.iterator();
- while (it.hasNext())
- {
- ((ConnectionListener) it.next()).handleConnectionException(ex, client);
- }
+ localListeners = new ArrayList(listeners);
}
+
+ Iterator it = localListeners.iterator();
+ while (it.hasNext())
+ {
+ ((ConnectionListener) it.next()).handleConnectionException(ex, client);
+ }
}
catch(Exception e)
{
Show replies by date