[Red5commits] [1586] keep children and clients in ConcurrentHashMaps? to avoid ConcurrentModification
jbauch
luke at codegent.com
Wed Jan 24 11:00:07 EST 2007
keep children and clients in ConcurrentHashMaps? to avoid ConcurrentModificationExceptions? when using the iterators (APPSERVER-15 and APPSERVER-22)
Timestamp: 12/11/06 17:24:06 EST (1 month ago)
Change: 1586
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/1586
Index: /java/server/trunk/src/org/red5/server/Scope.java
===================================================================
--- /java/server/trunk/src/org/red5/server/Scope.java (revision 1580)
+++ /java/server/trunk/src/org/red5/server/Scope.java (revision 1586)
@@ -26,4 +26,5 @@
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
@@ -65,7 +66,7 @@
private boolean running;
- private HashMap<String, IBasicScope> children = new HashMap<String, IBasicScope>();
-
- private HashMap<IClient, Set<IConnection>> clients = new HashMap<IClient, Set<IConnection>>();
+ private Map<String, IBasicScope> children = new ConcurrentHashMap<String, IBasicScope>();
+
+ private Map<IClient, Set<IConnection>> clients = new ConcurrentHashMap<IClient, Set<IConnection>>();
public Scope() {
@@ -461,8 +462,5 @@
public ConnectionIterator() {
- // 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();
+ setIterator = clients.values().iterator();
}
@@ -477,5 +475,5 @@
return null;
}
- connIterator = new HashSet<IConnection>(setIterator.next()).iterator();
+ connIterator = 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