Buggy code:
void setArcusReplEnabled ( boolean b ) { } boolean getArcusReplEnabled ( ) { } private boolean selectorsMakeSense ( ) { } public void handleIO ( ) throws IOException { } public void updateConnections ( List < InetSocketAddress > addrs ) throws IOException { List < MemcachedNode > attachNodes = new ArrayList < MemcachedNode > ( ) ; List < MemcachedNode > removeNodes = new ArrayList < MemcachedNode > ( ) ; List < MemcachedReplicaGroup > changeRoleGroups = new ArrayList < MemcachedReplicaGroup > ( ) ; if ( arcusReplEnabled ) { Map < String , List < ArcusReplNodeAddress > > newAllGroups = ArcusReplNodeAddress . makeGroupAddrsList ( addrs ) ; Map < String , MemcachedReplicaGroup > oldAllGroups = ( ( ArcusReplKetamaNodeLocator ) ( locator ) ) . getAllGroups ( ) ; for ( Map . Entry < String , MemcachedReplicaGroup > entry : oldAllGroups . entrySet ( ) ) { MemcachedReplicaGroup oldGroup = entry . getValue ( ) ; List < ArcusReplNodeAddress > newGroupAddrs = newAllGroups . get ( entry . getKey ( ) ) ; arcusLogger . debug ( ( "New<seq2seq4repair_space>group<seq2seq4repair_space>nodes<seq2seq4repair_space>:<seq2seq4repair_space>" + newGroupAddrs ) ) ; arcusLogger . debug ( ( ( "Old<seq2seq4repair_space>group<seq2seq4repair_space>nodes<seq2seq4repair_space>:<seq2seq4repair_space>[" + ( entry . getValue ( ) ) ) + "]" ) ) ; if ( newGroupAddrs == null ) { removeNodes . add ( oldGroup . getMasterNode ( ) ) ; if ( ( oldGroup . getSlaveNode ( ) ) != null ) removeNodes . add ( oldGroup . getSlaveNode ( ) ) ; continue ; } if ( ( newGroupAddrs . size ( ) ) == 0 ) { newAllGroups . remove ( entry . getKey ( ) ) ; continue ; } ArcusReplNodeAddress oldMasterAddr = ( ( oldGroup . getMasterNode ( ) ) != null ) ? ( ( ArcusReplNodeAddress ) ( oldGroup . getMasterNode ( ) . getSocketAddress ( ) ) ) : null ; ArcusReplNodeAddress oldSlaveAddr = ( ( oldGroup . getSlaveNode ( ) ) != null ) ? ( ( ArcusReplNodeAddress ) ( oldGroup . getSlaveNode ( ) . getSocketAddress ( ) ) ) : null ; assert oldMasterAddr != null ; if ( ( newGroupAddrs . size ( ) ) == 1 ) { if ( oldSlaveAddr == null ) { if ( newGroupAddrs . get ( 0 ) . getIPPort ( ) . equals ( oldMasterAddr . getIPPort ( ) ) ) { } else { removeNodes . add ( oldGroup . getMasterNode ( ) ) ; attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 0 ) ) ) ; } } else { if ( newGroupAddrs . get ( 0 ) . getIPPort ( ) . equals ( oldMasterAddr . getIPPort ( ) ) ) { removeNodes . add ( oldGroup . getSlaveNode ( ) ) ; } else if ( newGroupAddrs . get ( 0 ) . getIPPort ( ) . equals ( oldSlaveAddr . getIPPort ( ) ) ) { removeNodes . add ( oldGroup . getMasterNode ( ) ) ; changeRoleGroups . add ( oldGroup ) ; } else { removeNodes . add ( oldGroup . getMasterNode ( ) ) ; removeNodes . add ( oldGroup . getSlaveNode ( ) ) ; attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 0 ) ) ) ; } } } else { if ( oldSlaveAddr == null ) { if ( newGroupAddrs . get ( 0 ) . getIPPort ( ) . equals ( oldMasterAddr . getIPPort ( ) ) ) { attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 1 ) ) ) ; } else if ( newGroupAddrs . get ( 1 ) . getIPPort ( ) . equals ( oldMasterAddr . getIPPort ( ) ) ) { changeRoleGroups . add ( oldGroup ) ; attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 0 ) ) ) ; } else { removeNodes . add ( oldGroup . getMasterNode ( ) ) ; attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 0 ) ) ) ; attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 1 ) ) ) ; } } else { if ( newGroupAddrs . get ( 0 ) . getIPPort ( ) . equals ( oldMasterAddr . getIPPort ( ) ) ) { <START_BUG> if ( ( newGroupAddrs . get ( 1 ) ) == ( oldGroup . getSlaveNode ( ) . getSocketAddress ( ) ) ) { <END_BUG> } else { removeNodes . add ( oldGroup . getSlaveNode ( ) ) ; attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 1 ) ) ) ; } } else if ( newGroupAddrs . get ( 0 ) . getIPPort ( ) . equals ( oldSlaveAddr . getIPPort ( ) ) ) { if ( newGroupAddrs . get ( 1 ) . getIPPort ( ) . equals ( oldMasterAddr . getIPPort ( ) ) ) { changeRoleGroups . add ( oldGroup ) ; } else { removeNodes . add ( oldGroup . getMasterNode ( ) ) ; changeRoleGroups . add ( oldGroup ) ; attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 1 ) ) ) ; } } else { if ( newGroupAddrs . get ( 1 ) . getIPPort ( ) . equals ( oldMasterAddr . getIPPort ( ) ) ) { removeNodes . add ( oldGroup . getSlaveNode ( ) ) ; changeRoleGroups . add ( oldGroup ) ; } else if ( newGroupAddrs . get ( 1 ) . getIPPort ( ) . equals ( oldSlaveAddr . getIPPort ( ) ) ) { removeNodes . add ( oldGroup . getMasterNode ( ) ) ; } else { removeNodes . add ( oldGroup . getMasterNode ( ) ) ; removeNodes . add ( oldGroup . getSlaveNode ( ) ) ; attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 1 ) ) ) ; } attachNodes . add ( attachMemcachedNode ( newGroupAddrs . get ( 0 ) ) ) ; } } }

Fix:
if ( newGroupAddrs . get ( 1 ) . getIPPort ( ) . equals ( oldSlaveAddr . getIPPort ( ) ) ) {