[Red5commits] [1580] ConnectionIterator? now traverses over a copy of the internal list to prevent Co

jbauch luke at codegent.com
Wed Jan 24 10:59:13 EST 2007


ConnectionIterator? now traverses over a copy of the internal list to prevent ConcurrentModificationException?, that should fix APPSERVER-15


Timestamp: 11/28/06 18:11:31 EST (2 months ago) 
Change: 1580 
Author: jbauch

Files (see diff or trac for details): 
java/server/trunk/src/org/red5/server/Scope.java


Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1580

Index: /java/server/trunk/src/org/red5/server/Scope.java
===================================================================
--- /java/server/trunk/src/org/red5/server/Scope.java (revision 1519)
+++ /java/server/trunk/src/org/red5/server/Scope.java (revision 1580)
@@ -454,12 +454,15 @@
 	class ConnectionIterator implements Iterator<IConnection> {
 
-		private Iterator setIterator;
-
-		private Iterator connIterator;
+		private Iterator<Set<IConnection>> setIterator;
+
+		private Iterator<IConnection> connIterator;
 
 		private IConnection current;
 
 		public ConnectionIterator() {
-			setIterator = clients.values().iterator();
+			// NOTE: we create a copy of the client connections here
+			//       to prevent ConcurrentModificationExceptions while
+			//       traversing the iterator.
+			setIterator = new HashSet<Set<IConnection>>(clients.values()).iterator();
 		}
 
@@ -474,5 +477,5 @@
 					return null;
 				}
-				connIterator = ((Set) setIterator.next()).iterator();
+				connIterator = new HashSet<IConnection>(setIterator.next()).iterator();
 			}
 			current = (IConnection) connIterator.next();


Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.



More information about the Red5commits mailing list