Program: 35192
Project: 35192
Buggy source:
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());
      ArcusClient.arcusLogger.debug("String_Node_Str" + newGroupAddrs);
      ArcusClient.arcusLogger.debug("String_Node_Str" + entry.getValue() + "String_Node_Str");
      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())) {
            if (newGroupAddrs.get(1) == oldGroup.getSlaveNode().getSocketAddress()) {
            }
 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)));
          }
        }
      }
      newAllGroups.remove(entry.getKey());
    }
    for (    Map.Entry<String,List<ArcusReplNodeAddress>> entry : newAllGroups.entrySet()) {
      List<ArcusReplNodeAddress> newGroupAddrs=entry.getValue();
      if (newGroupAddrs.size() == 0) {
        attachNodes.add(attachMemcachedNode(ArcusReplNodeAddress.createFake(entry.getKey())));
      }
 else {
        attachNodes.add(attachMemcachedNode(newGroupAddrs.get(0)));
        if (newGroupAddrs.size() > 1)         attachNodes.add(attachMemcachedNode(newGroupAddrs.get(1)));
      }
    }
  }
 else {
    for (    MemcachedNode node : locator.getAll()) {
      if (addrs.contains((InetSocketAddress)node.getSocketAddress())) {
        addrs.remove((InetSocketAddress)node.getSocketAddress());
      }
 else {
        removeNodes.add(node);
      }
    }
    for (    SocketAddress sa : addrs) {
      attachNodes.add(attachMemcachedNode(sa));
    }
  }
  for (  MemcachedNode node : removeNodes) {
    getLogger().info("String_Node_Str",node);
    for (    Entry<Long,MemcachedNode> each : reconnectQueue.entrySet()) {
      if (node.equals(each.getValue())) {
        reconnectQueue.remove(each.getKey());
        break;
      }
    }
  }
  if (arcusReplEnabled && changeRoleGroups.size() > 0)   ((ArcusReplKetamaNodeLocator)locator).update(attachNodes,removeNodes,changeRoleGroups);
 else   locator.update(attachNodes,removeNodes);
}

Fixed version (ground truth):
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());
      ArcusClient.arcusLogger.debug("String_Node_Str" + newGroupAddrs);
      ArcusClient.arcusLogger.debug("String_Node_Str" + entry.getValue() + "String_Node_Str");
      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())) {
            if (newGroupAddrs.get(1).getIPPort().equals(oldSlaveAddr.getIPPort())) {
            }
 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)));
          }
        }
      }
      newAllGroups.remove(entry.getKey());
    }
    for (    Map.Entry<String,List<ArcusReplNodeAddress>> entry : newAllGroups.entrySet()) {
      List<ArcusReplNodeAddress> newGroupAddrs=entry.getValue();
      if (newGroupAddrs.size() == 0) {
        attachNodes.add(attachMemcachedNode(ArcusReplNodeAddress.createFake(entry.getKey())));
      }
 else {
        attachNodes.add(attachMemcachedNode(newGroupAddrs.get(0)));
        if (newGroupAddrs.size() > 1)         attachNodes.add(attachMemcachedNode(newGroupAddrs.get(1)));
      }
    }
  }
 else {
    for (    MemcachedNode node : locator.getAll()) {
      if (addrs.contains((InetSocketAddress)node.getSocketAddress())) {
        addrs.remove((InetSocketAddress)node.getSocketAddress());
      }
 else {
        removeNodes.add(node);
      }
    }
    for (    SocketAddress sa : addrs) {
      attachNodes.add(attachMemcachedNode(sa));
    }
  }
  for (  MemcachedNode node : removeNodes) {
    getLogger().info("String_Node_Str",node);
    for (    Entry<Long,MemcachedNode> each : reconnectQueue.entrySet()) {
      if (node.equals(each.getValue())) {
        reconnectQueue.remove(each.getKey());
        break;
      }
    }
  }
  if (arcusReplEnabled && changeRoleGroups.size() > 0)   ((ArcusReplKetamaNodeLocator)locator).update(attachNodes,removeNodes,changeRoleGroups);
 else   locator.update(attachNodes,removeNodes);
}