Permalink
Browse files

[JGRP-1383] Fix race condition in BasicConnectionTable.retainAll by

adding appropriate synchronization in BasicTCP.handleDownEvent.
  • Loading branch information...
dereed committed Nov 2, 2011
1 parent de2dbe7 commit da732f7cd05c270c6e09d44361b4826ec3f2f617
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/org/jgroups/protocols/BasicTCP.java
@@ -10,6 +10,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@@ -262,8 +263,12 @@ protected Object handleDownEvent(Event evt) {
Object ret=super.handleDownEvent(evt);
if(evt.getType() == Event.VIEW_CHANGE) {
suspected_mbrs.clear();
- retainAll(members); // remove all connections from the ConnectionTable which are not members
+ HashSet<Address> copy;
+ synchronized(members) {
+ copy=new HashSet<Address>(members);
}
+ retainAll(copy);
+ }
else if(evt.getType() == Event.UNSUSPECT) {
Address suspected_mbr=(Address)evt.getArg();
suspected_mbrs.remove(suspected_mbr);

0 comments on commit da732f7

Please sign in to comment.