You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2006/07/18 23:03:22 UTC
svn commit: r423243 -
/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
Author: fhanik
Date: Tue Jul 18 14:03:21 2006
New Revision: 423243
URL: http://svn.apache.org/viewvc?rev=423243&view=rev
Log:
Single op reduces the risk of ConcurrentModification exception, although they still occur. the correct solution is to implement an atomic size counter
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java?rev=423243&r1=423242&r2=423243&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tipis/AbstractReplicatedMap.java Tue Jul 18 14:03:21 2006
@@ -45,6 +45,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.catalina.tribes.util.Arrays;
+import java.util.ConcurrentModificationException;
/**
* <p>Title: </p>
@@ -860,11 +861,13 @@
//todo, implement a counter variable instead
//only count active members in this node
int counter = 0;
- Iterator i = super.entrySet().iterator();
- while ( i.hasNext() ) {
- Map.Entry e = (Map.Entry)i.next();
- MapEntry entry = (MapEntry)e.getValue();
- if ( entry.isPrimary() && entry.getValue()!=null ) counter++;
+ Object[] items = super.entrySet().toArray();
+ for (int i=0; i<items.length; i++ ) {
+ Map.Entry e = (Map.Entry) items[i];
+ if ( e != null ) {
+ MapEntry entry = (MapEntry) e.getValue();
+ if (entry.isPrimary() && entry.getValue() != null) counter++;
+ }
}
return counter;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org