nus-yam/ex-repair huggingface dataset:
Program: 130746
Project: 130746
Buggy source:
public void follow(String leader) throws Exception {
  this.electedLeader=leader;
  try {
    changePhase(Phase.DISCOVERING);
    sendProposedEpoch();
    waitForNewEpoch();
    LOG.debug("String_Node_Str");
    changePhase(Phase.SYNCHRONIZING);
    long st=System.nanoTime();
    waitForSync(this.electedLeader);
    waitForNewLeaderMessage();
    waitForCommitMessage();
    long syncTime=System.nanoTime() - st;
    adjustSyncTimeout((int)(syncTime / 1000000));
    restoreFromSnapshot();
    deliverUndeliveredTxns();
    changePhase(Phase.BROADCASTING);
    LOG.info("String_Node_Str");
    accepting();
  }
 catch (  InterruptedException e) {
    LOG.debug("String_Node_Str");
    throw e;
  }
catch (  TimeoutException e) {
    LOG.debug("String_Node_Str" + "String_Node_Str",this.electedLeader,this.config.getTimeoutMs());
  }
catch (  BackToElectionException e) {
    LOG.debug("String_Node_Str");
  }
catch (  Zab.SimulatedException e) {
    LOG.debug("String_Node_Str");
  }
catch (  LeftCluster e) {
    LOG.debug("String_Node_Str",e.getMessage());
    throw e;
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw e;
  }
 finally {
    if (this.currentPhase == Phase.SYNCHRONIZING) {
      incSyncTimeout();
      LOG.debug("String_Node_Str" + "String_Node_Str",getSyncTimeoutMs());
    }
    changePhase(Phase.FINALIZING);
  }
}

Fixed version (ground truth):
public void follow(String leader) throws Exception {
  this.electedLeader=leader;
  try {
    changePhase(Phase.DISCOVERING);
    sendProposedEpoch();
    waitForNewEpoch();
    LOG.debug("String_Node_Str");
    changePhase(Phase.SYNCHRONIZING);
    long st=System.nanoTime();
    waitForSync(this.electedLeader);
    waitForNewLeaderMessage();
    waitForCommitMessage();
    long syncTime=System.nanoTime() - st;
    adjustSyncTimeout((int)(syncTime / 1000000));
    restoreFromSnapshot();
    deliverUndeliveredTxns();
    changePhase(Phase.BROADCASTING);
    accepting();
  }
 catch (  InterruptedException e) {
    LOG.debug("String_Node_Str");
    throw e;
  }
catch (  TimeoutException e) {
    LOG.debug("String_Node_Str" + "String_Node_Str",this.electedLeader,this.config.getTimeoutMs());
  }
catch (  BackToElectionException e) {
    LOG.debug("String_Node_Str");
  }
catch (  Zab.SimulatedException e) {
    LOG.debug("String_Node_Str");
  }
catch (  LeftCluster e) {
    LOG.debug("String_Node_Str",e.getMessage());
    throw e;
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw e;
  }
 finally {
    if (this.currentPhase == Phase.SYNCHRONIZING) {
      incSyncTimeout();
      LOG.debug("String_Node_Str" + "String_Node_Str",getSyncTimeoutMs());
    }
    changePhase(Phase.FINALIZING);
  }
}
Program: 130748
Project: 130748
Buggy source:
@Override protected void changePhase(Phase phase) throws IOException, InterruptedException, ExecutionException {
  this.currentPhase=phase;
  if (phase == Phase.DISCOVERING) {
    MDC.put("String_Node_Str","String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.leaderDiscovering(this.serverId);
    }
    if (failCallback != null) {
      failCallback.leaderDiscovering();
    }
  }
 else   if (phase == Phase.SYNCHRONIZING) {
    MDC.put("String_Node_Str","String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.leaderSynchronizing(persistence.getProposedEpoch());
    }
    if (failCallback != null) {
      failCallback.leaderSynchronizing();
    }
  }
 else   if (phase == Phase.BROADCASTING) {
    MDC.put("String_Node_Str","String_Node_Str");
    this.isBroadcasting=true;
    if (failCallback != null) {
      failCallback.leaderBroadcasting();
    }
    if (stateChangeCallback != null) {
      stateChangeCallback.leaderBroadcasting(persistence.getAckEpoch(),getAllTxns(),persistence.getLastSeenConfig());
    }
  }
 else   if (phase == Phase.FINALIZING) {
    MDC.put("String_Node_Str","String_Node_Str");
    this.stateMachine.recovering();
    for (    PeerHandler ph : this.quorumSet.values()) {
      ph.shutdown();
      this.quorumSet.remove(ph.getServerId());
    }
    this.semPendingReqs.release(ZabConfig.MAX_PENDING_REQS);
  }
}

Fixed version (ground truth):
@Override protected void changePhase(Phase phase) throws IOException, InterruptedException, ExecutionException {
  this.currentPhase=phase;
  if (phase == Phase.DISCOVERING) {
    MDC.put("String_Node_Str","String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.leaderDiscovering(this.serverId);
    }
    if (failCallback != null) {
      failCallback.leaderDiscovering();
    }
  }
 else   if (phase == Phase.SYNCHRONIZING) {
    MDC.put("String_Node_Str","String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.leaderSynchronizing(persistence.getProposedEpoch());
    }
    if (failCallback != null) {
      failCallback.leaderSynchronizing();
    }
  }
 else   if (phase == Phase.BROADCASTING) {
    MDC.put("String_Node_Str","String_Node_Str");
    if (failCallback != null) {
      failCallback.leaderBroadcasting();
    }
    if (stateChangeCallback != null) {
      stateChangeCallback.leaderBroadcasting(persistence.getAckEpoch(),getAllTxns(),persistence.getLastSeenConfig());
    }
  }
 else   if (phase == Phase.FINALIZING) {
    MDC.put("String_Node_Str","String_Node_Str");
    this.stateMachine.recovering();
    for (    PeerHandler ph : this.quorumSet.values()) {
      ph.shutdown();
      this.quorumSet.remove(ph.getServerId());
    }
    this.semPendingReqs.release(ZabConfig.MAX_PENDING_REQS);
  }
}
Program: 130753
Project: 130753
Buggy source:
@Test(timeout=3000) public void testRemove() throws Exception {
  String server1=getUniqueHostPort();
  String server2=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  TestReceiver receiver2=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  NettyTransport transport2=new NettyTransport(server2,receiver2,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  PeerHandler ph2=new PeerHandler(server2,transport2,10000);
  ph1.startBroadcastingTask();
  ph2.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  peers.add(server2);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  quorumSet.put(server2,ph2);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  ackProcessor.processRequest(createRemove(server2,new Zxid(0,2)));
  ackProcessor.processRequest(createAck(server1,new Zxid(0,3)));
  receiver1.latch.await();
  receiver2.latch.await();
  Assert.assertEquals(new Zxid(0,3),receiver1.committedZxids.get(0));
  Assert.assertEquals(new Zxid(0,3),receiver2.committedZxids.get(0));
  Assert.assertEquals(1,receiver1.committedZxids.size());
  Assert.assertEquals(1,receiver2.committedZxids.size());
}

Fixed version (ground truth):
@Test(timeout=3000) public void testRemove() throws Exception {
  String server1=getUniqueHostPort();
  String server2=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  TestReceiver receiver2=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  NettyTransport transport2=new NettyTransport(server2,receiver2,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  PeerHandler ph2=new PeerHandler(server2,transport2,10000);
  ph1.startBroadcastingTask();
  ph2.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  peers.add(server2);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  quorumSet.put(server2,ph2);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  ackProcessor.processRequest(createRemove(server2,new Zxid(0,2)));
  ackProcessor.processRequest(createAck(server1,new Zxid(0,3)));
  receiver1.latch.await();
  receiver2.latch.await();
  Assert.assertEquals(new Zxid(0,3),receiver1.committedZxids.get(0));
  Assert.assertEquals(new Zxid(0,3),receiver2.committedZxids.get(0));
  Assert.assertEquals(1,receiver1.committedZxids.size());
  Assert.assertEquals(1,receiver2.committedZxids.size());
  ackProcessor.shutdown();
}
Program: 130754
Project: 130754
Buggy source:
@Test(timeout=3000) public void testAllAck() throws Exception {
  String server1=getUniqueHostPort();
  String server2=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  TestReceiver receiver2=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  NettyTransport transport2=new NettyTransport(server2,receiver2,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  PeerHandler ph2=new PeerHandler(server2,transport2,10000);
  ph1.startBroadcastingTask();
  ph2.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  peers.add(server2);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  quorumSet.put(server2,ph2);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  Zxid z1=new Zxid(0,0);
  ackProcessor.processRequest(createAck(server1,z1));
  ackProcessor.processRequest(createAck(server2,z1));
  receiver1.latch.await();
  receiver2.latch.await();
}

Fixed version (ground truth):
@Test(timeout=3000) public void testAllAck() throws Exception {
  String server1=getUniqueHostPort();
  String server2=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  TestReceiver receiver2=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  NettyTransport transport2=new NettyTransport(server2,receiver2,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  PeerHandler ph2=new PeerHandler(server2,transport2,10000);
  ph1.startBroadcastingTask();
  ph2.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  peers.add(server2);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  quorumSet.put(server2,ph2);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  Zxid z1=new Zxid(0,0);
  ackProcessor.processRequest(createAck(server1,z1));
  ackProcessor.processRequest(createAck(server2,z1));
  receiver1.latch.await();
  receiver2.latch.await();
  ackProcessor.shutdown();
}
Program: 130756
Project: 130756
Buggy source:
@Test(timeout=3000) public void testRemoveItself() throws Exception {
  String server1=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  ph1.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  Zxid z1=new Zxid(0,0);
  ackProcessor.processRequest(createRemove(server1,z1));
  ackProcessor.processRequest(createAck(server1,z1));
  receiver1.latch.await();
}

Fixed version (ground truth):
@Test(timeout=3000) public void testRemoveItself() throws Exception {
  String server1=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  ph1.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  Zxid z1=new Zxid(0,0);
  ackProcessor.processRequest(createRemove(server1,z1));
  ackProcessor.processRequest(createAck(server1,z1));
  receiver1.latch.await();
  ackProcessor.shutdown();
}
Program: 130757
Project: 130757
Buggy source:
@Test(timeout=3000) public void testQuorumAck() throws Exception {
  String server1=getUniqueHostPort();
  String server2=getUniqueHostPort();
  String server3=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  TestReceiver receiver2=new TestReceiver(1);
  TestReceiver receiver3=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  NettyTransport transport2=new NettyTransport(server2,receiver2,getDirectory());
  NettyTransport transport3=new NettyTransport(server3,receiver3,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  PeerHandler ph2=new PeerHandler(server2,transport2,10000);
  PeerHandler ph3=new PeerHandler(server3,transport3,10000);
  ph1.startBroadcastingTask();
  ph2.startBroadcastingTask();
  ph3.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  peers.add(server2);
  peers.add(server3);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  quorumSet.put(server2,ph2);
  quorumSet.put(server3,ph3);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  Zxid z1=new Zxid(0,0);
  ackProcessor.processRequest(createAck(server1,z1));
  ackProcessor.processRequest(createAck(server2,z1));
  receiver1.latch.await();
  receiver2.latch.await();
  receiver3.latch.await();
}

Fixed version (ground truth):
@Test(timeout=3000) public void testQuorumAck() throws Exception {
  String server1=getUniqueHostPort();
  String server2=getUniqueHostPort();
  String server3=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  TestReceiver receiver2=new TestReceiver(1);
  TestReceiver receiver3=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  NettyTransport transport2=new NettyTransport(server2,receiver2,getDirectory());
  NettyTransport transport3=new NettyTransport(server3,receiver3,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  PeerHandler ph2=new PeerHandler(server2,transport2,10000);
  PeerHandler ph3=new PeerHandler(server3,transport3,10000);
  ph1.startBroadcastingTask();
  ph2.startBroadcastingTask();
  ph3.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  peers.add(server2);
  peers.add(server3);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  quorumSet.put(server2,ph2);
  quorumSet.put(server3,ph3);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  Zxid z1=new Zxid(0,0);
  ackProcessor.processRequest(createAck(server1,z1));
  ackProcessor.processRequest(createAck(server2,z1));
  receiver1.latch.await();
  receiver2.latch.await();
  receiver3.latch.await();
  ackProcessor.shutdown();
}
Program: 130759
Project: 130759
Buggy source:
@Test(timeout=3000) public void testJoin() throws Exception {
  String server1=getUniqueHostPort();
  String server2=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  TestReceiver receiver2=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  NettyTransport transport2=new NettyTransport(server2,receiver2,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  PeerHandler ph2=new PeerHandler(server2,transport2,10000);
  ph1.startBroadcastingTask();
  ph2.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  quorumSet.put(server2,ph2);
  ackProcessor.processRequest(createJoin(server2,new Zxid(0,2)));
  ackProcessor.processRequest(createAck(server1,new Zxid(0,10)));
  receiver1.latch.await();
  receiver2.latch.await();
  Assert.assertEquals(new Zxid(0,1),receiver1.committedZxids.get(0));
  Assert.assertEquals(new Zxid(0,1),receiver2.committedZxids.get(0));
  Assert.assertEquals(1,receiver1.committedZxids.size());
  Assert.assertEquals(1,receiver2.committedZxids.size());
}

Fixed version (ground truth):
@Test(timeout=3000) public void testJoin() throws Exception {
  String server1=getUniqueHostPort();
  String server2=getUniqueHostPort();
  TestReceiver receiver1=new TestReceiver(1);
  TestReceiver receiver2=new TestReceiver(1);
  NettyTransport transport1=new NettyTransport(server1,receiver1,getDirectory());
  NettyTransport transport2=new NettyTransport(server2,receiver2,getDirectory());
  PeerHandler ph1=new PeerHandler(server1,transport1,10000);
  PeerHandler ph2=new PeerHandler(server2,transport2,10000);
  ph1.startBroadcastingTask();
  ph2.startBroadcastingTask();
  List<String> peers=new ArrayList<String>();
  peers.add(server1);
  HashMap<String,PeerHandler> quorumSet=new HashMap<String,PeerHandler>();
  quorumSet.put(server1,ph1);
  ClusterConfiguration cnf=new ClusterConfiguration(Zxid.ZXID_NOT_EXIST,peers,server1);
  AckProcessor ackProcessor=new AckProcessor(quorumSet,cnf,Zxid.ZXID_NOT_EXIST);
  quorumSet.put(server2,ph2);
  ackProcessor.processRequest(createJoin(server2,new Zxid(0,2)));
  ackProcessor.processRequest(createAck(server1,new Zxid(0,10)));
  receiver1.latch.await();
  receiver2.latch.await();
  Assert.assertEquals(new Zxid(0,1),receiver1.committedZxids.get(0));
  Assert.assertEquals(new Zxid(0,1),receiver2.committedZxids.get(0));
  Assert.assertEquals(1,receiver1.committedZxids.size());
  Assert.assertEquals(1,receiver2.committedZxids.size());
  ackProcessor.shutdown();
}
Program: 130762
Project: 130762
Buggy source:
void onJoin(MessageTuple tuple,PreProcessor preProcessor,AckProcessor ackProcessor,CommitProcessor commitProcessor,ClusterConfiguration clusterConfig) throws IOException {
  String source=tuple.getServerId();
  PeerHandler ph=new PeerHandler(source,transport,config.getTimeout() / 3);
  ph.setLastZxid(Zxid.ZXID_NOT_EXIST);
  ph.setLastSyncedZxid(tuple.getZxid());
  clusterConfig.addPeer(source);
  quorumSet.put(source,ph);
  pendingPeers.put(source,ph);
  preProcessor.processRequest(tuple);
  ackProcessor.processRequest(tuple);
  commitProcessor.processRequest(tuple);
}

Fixed version (ground truth):
void onJoin(MessageTuple tuple,PreProcessor preProcessor,AckProcessor ackProcessor,CommitProcessor commitProcessor,ClusterConfiguration clusterConfig) throws IOException {
  Zxid lastZxid=MessageBuilder.fromProtoZxid(tuple.getMessage().getJoin().getLastZxid());
  String source=tuple.getServerId();
  PeerHandler ph=new PeerHandler(source,transport,config.getTimeout() / 3);
  ph.setLastZxid(lastZxid);
  ph.setLastSyncedZxid(tuple.getZxid());
  clusterConfig.addPeer(source);
  quorumSet.put(source,ph);
  pendingPeers.put(source,ph);
  preProcessor.processRequest(tuple);
  ackProcessor.processRequest(tuple);
  commitProcessor.processRequest(tuple);
}
Program: 130763
Project: 130763
Buggy source:
/** 
 * Creates a JOIN message.
 * @return a protobuf message.
 */
public static Message buildJoin(){
  return Message.newBuilder().setType(MessageType.JOIN).build();
}

Fixed version (ground truth):
/** 
 * Creates a JOIN message.
 * @return a protobuf message.
 */
public static Message buildJoin(Zxid lastZxid){
  ZabMessage.Zxid zxid=toProtoZxid(lastZxid);
  ZabMessage.Join join=ZabMessage.Join.newBuilder().setLastZxid(zxid).build();
  return Message.newBuilder().setType(MessageType.JOIN).setJoin(join).build();
}
Program: 130764
Project: 130764
Buggy source:
@Override public Void call() throws Exception {
  LOG.debug("String_Node_Str");
  try {
    BlockingQueue<MessageTuple> requestQueue=participantState.getRequestQueue();
    while (true) {
      MessageTuple tuple=requestQueue.take();
      if (tuple == MessageTuple.REQUEST_OF_DEATH) {
        return null;
      }
      semPendingReqs.acquire();
      sendMessage(this.leader,tuple.getMessage());
    }
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str");
    throw e;
  }
}

Fixed version (ground truth):
@Override public Void call() throws Exception {
  LOG.debug("String_Node_Str");
  try {
    BlockingQueue<MessageTuple> requestQueue=participantState.getRequestQueue();
    while (!stop) {
      MessageTuple tuple=requestQueue.poll(500,TimeUnit.MILLISECONDS);
      if (tuple == null) {
        continue;
      }
      semPendingReqs.acquire();
      sendMessage(this.leader,tuple.getMessage());
    }
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str");
    throw e;
  }
  return null;
}
Program: 130765
Project: 130765
Buggy source:
public void shutdown() throws ExecutionException, InterruptedException {
  participantState.getRequestQueue().add(MessageTuple.REQUEST_OF_DEATH);
  this.ft.get();
  LOG.debug("String_Node_Str");
}

Fixed version (ground truth):
public void shutdown() throws ExecutionException, InterruptedException {
  this.stop=true;
  semPendingReqs.release();
  this.ft.get();
  LOG.debug("String_Node_Str");
}
Program: 130767
Project: 130767
Buggy source:
private Zxid getCommittedZxid(ClusterConfiguration cnf){
  ArrayList<Zxid> zxids=new ArrayList<Zxid>();
  for (  PeerHandler ph : quorumSet.values()) {
    LOG.debug("String_Node_Str",ph.getServerId(),ph.getLastAckedZxid());
    Zxid ackZxid=ph.getLastAckedZxid();
    if (ackZxid != null && cnf.contains(ph.getServerId())) {
      zxids.add(ph.getLastAckedZxid());
    }
  }
  int quorumSize=cnf.getQuorumSize();
  if (zxids.size() < quorumSize) {
    return this.lastCommittedZxid;
  }
  Collections.sort(zxids);
  return zxids.get(zxids.size() - quorumSize);
}

Fixed version (ground truth):
private Zxid getCommittedZxid(ClusterConfiguration cnf){
  ArrayList<Zxid> zxids=new ArrayList<Zxid>();
  LOG.debug("String_Node_Str",cnf.getVersion());
  for (  PeerHandler ph : quorumSet.values()) {
    Zxid ackZxid=ph.getLastAckedZxid();
    if (cnf.contains(ph.getServerId())) {
      if (ackZxid != null) {
        zxids.add(ackZxid);
      }
      LOG.debug("String_Node_Str",ph.getServerId(),ackZxid);
    }
  }
  int quorumSize=cnf.getQuorumSize();
  if (quorumSize == 0) {
    return cnf.getVersion();
  }
  if (zxids.size() < quorumSize) {
    return Zxid.ZXID_NOT_EXIST;
  }
  Collections.sort(zxids);
  return zxids.get(zxids.size() - quorumSize);
}
Program: 130768
Project: 130768
Buggy source:
/** 
 * Gets the minimal quorum size.
 */
public int getQuorumSize(){
  return this.getPeers().size() / 2 + 1;
}

Fixed version (ground truth):
/** 
 * Gets the minimal quorum size.
 */
public int getQuorumSize(){
  int clusterSize=this.getPeers().size();
  if (clusterSize == 0) {
    return 0;
  }
 else {
    return clusterSize / 2 + 1;
  }
}
Program: 130769
Project: 130769
Buggy source:
void onCommit(MessageTuple tuple,CommitProcessor commitProcessor){
  Message msg=tuple.getMessage();
  if (!pendingPeers.isEmpty()) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",TextFormat.shortDebugString(msg));
    }
    Zxid zxidCommit=MessageBuilder.fromProtoZxid(msg.getCommit().getZxid());
    Iterator<Map.Entry<String,PeerHandler>> iter=pendingPeers.entrySet().iterator();
    while (iter.hasNext()) {
      PeerHandler ph=iter.next().getValue();
      Zxid ackZxid=ph.getLastAckedZxid();
      if (ackZxid != null && zxidCommit.compareTo(ackZxid) >= 0) {
        LOG.debug("String_Node_Str");
        Message commit=MessageBuilder.buildCommit(ackZxid);
        sendMessage(ph.getServerId(),commit);
        ph.startBroadcastingTask();
        iter.remove();
      }
    }
  }
  commitProcessor.processRequest(tuple);
}

Fixed version (ground truth):
void onCommit(MessageTuple tuple,CommitProcessor commitProcessor){
  Message msg=tuple.getMessage();
  this.lastCommittedZxid=MessageBuilder.fromProtoZxid(msg.getCommit().getZxid());
  if (pendingCopZxid != null && lastCommittedZxid.compareTo(this.pendingCopZxid) >= 0) {
    LOG.debug("String_Node_Str",pendingCopZxid);
    pendingCopZxid=null;
    if (stateChangeCallback != null) {
      stateChangeCallback.commitCop();
    }
  }
  if (!pendingPeers.isEmpty()) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("String_Node_Str",TextFormat.shortDebugString(msg));
    }
    Zxid zxidCommit=this.lastCommittedZxid;
    Iterator<Map.Entry<String,PeerHandler>> iter=pendingPeers.entrySet().iterator();
    while (iter.hasNext()) {
      PeerHandler ph=iter.next().getValue();
      Zxid ackZxid=ph.getLastAckedZxid();
      if (ackZxid != null && zxidCommit.compareTo(ackZxid) >= 0) {
        LOG.debug("String_Node_Str",ackZxid);
        Message commit=MessageBuilder.buildCommit(ackZxid);
        sendMessage(ph.getServerId(),commit);
        ph.startBroadcastingTask();
        iter.remove();
      }
    }
  }
  commitProcessor.processRequest(tuple);
}
Program: 130771
Project: 130771
Buggy source:
@Override public Void call() throws Exception {
  Election electionAlg=new RoundRobinElection();
  try {
    if (this.joinPeer != null) {
      stateMachine.recovering();
      join(this.joinPeer);
    }
    while (true) {
      PersistentState persistence=participantState.getPersistence();
      String leader=electionAlg.electLeader(persistence);
      LOG.debug("String_Node_Str",leader);
      if (leader.equals(serverId)) {
        Participant participant=new Leader(participantState,stateMachine,config);
        participant.setStateChangeCallback(stateChangeCallback);
        participant.setFailureCaseCallback(failureCallback);
        ((Leader)participant).lead();
      }
 else {
        Participant participant=new Follower(participantState,stateMachine,config);
        participant.setStateChangeCallback(stateChangeCallback);
        participant.setFailureCaseCallback(failureCallback);
        ((Follower)participant).follow(leader);
      }
    }
  }
 catch (  InterruptedException e) {
    LOG.debug("String_Node_Str");
    participantState.getTransport().shutdown();
  }
catch (  Participant.LeftCluster e) {
    LOG.debug("String_Node_Str");
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw e;
  }
  if (stateChangeCallback != null) {
    stateChangeCallback.leftCluster();
  }
  return null;
}

Fixed version (ground truth):
@Override public Void call() throws Exception {
  Election electionAlg=new RoundRobinElection();
  try {
    if (this.joinPeer != null) {
      stateMachine.recovering();
      join(this.joinPeer);
    }
    while (true) {
      stateMachine.recovering();
      PersistentState persistence=participantState.getPersistence();
      String leader=electionAlg.electLeader(persistence);
      LOG.debug("String_Node_Str",leader);
      if (leader.equals(serverId)) {
        Participant participant=new Leader(participantState,stateMachine,config);
        participant.setStateChangeCallback(stateChangeCallback);
        participant.setFailureCaseCallback(failureCallback);
        ((Leader)participant).lead();
      }
 else {
        Participant participant=new Follower(participantState,stateMachine,config);
        participant.setStateChangeCallback(stateChangeCallback);
        participant.setFailureCaseCallback(failureCallback);
        ((Follower)participant).follow(leader);
      }
    }
  }
 catch (  InterruptedException e) {
    LOG.debug("String_Node_Str");
    participantState.getTransport().shutdown();
  }
catch (  Participant.LeftCluster e) {
    LOG.debug("String_Node_Str");
  }
catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw e;
  }
  if (stateChangeCallback != null) {
    stateChangeCallback.leftCluster();
  }
  return null;
}
Program: 130772
Project: 130772
Buggy source:
@Override public Void call() throws Exception {
  LOG.debug("String_Node_Str");
  try {
    while (true) {
      Request request=ackQueue.take();
      if (request == Request.REQUEST_OF_DEATH) {
        break;
      }
      String source=request.getServerId();
      ZabMessage.Ack ack=request.getMessage().getAck();
      Zxid zxid=MessageBuilder.fromProtoZxid(ack.getZxid());
      this.quorumSet.get(source).setLastAckedZxid(zxid);
      ArrayList<Zxid> zxids=new ArrayList<Zxid>();
      for (      PeerHandler ph : quorumSet.values()) {
        zxids.add(ph.getLastAckedZxid());
      }
      Collections.sort(zxids);
      Zxid zxidCanCommit=zxids.get(zxids.size() - this.quorumSize);
      LOG.debug("String_Node_Str",zxidCanCommit);
      if (zxidCanCommit.compareTo(Zxid.ZXID_NOT_EXIST) == 0) {
        continue;
      }
      LOG.debug("String_Node_Str",zxidCanCommit);
      Message commit=MessageBuilder.buildCommit(zxidCanCommit);
      for (      PeerHandler ph : quorumSet.values()) {
        ph.queueMessage(commit);
      }
    }
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw e;
  }
  LOG.debug("String_Node_Str");
  return null;
}

Fixed version (ground truth):
@Override public Void call() throws Exception {
  LOG.debug("String_Node_Str");
  try {
    while (true) {
      Request request=ackQueue.take();
      if (request == Request.REQUEST_OF_DEATH) {
        break;
      }
      String source=request.getServerId();
      ZabMessage.Ack ack=request.getMessage().getAck();
      Zxid zxid=MessageBuilder.fromProtoZxid(ack.getZxid());
      this.quorumSet.get(source).setLastAckedZxid(zxid);
      ArrayList<Zxid> zxids=new ArrayList<Zxid>();
      for (      PeerHandler ph : quorumSet.values()) {
        LOG.debug("String_Node_Str",ph.getServerId(),ph.getLastAckedZxid());
        zxids.add(ph.getLastAckedZxid());
      }
      Collections.sort(zxids);
      Zxid zxidCanCommit=zxids.get(zxids.size() - this.quorumSize);
      LOG.debug("String_Node_Str",zxidCanCommit);
      if (zxidCanCommit.compareTo(Zxid.ZXID_NOT_EXIST) == 0) {
        continue;
      }
      LOG.debug("String_Node_Str",zxidCanCommit);
      Message commit=MessageBuilder.buildCommit(zxidCanCommit);
      for (      PeerHandler ph : quorumSet.values()) {
        ph.queueMessage(commit);
      }
    }
  }
 catch (  Exception e) {
    LOG.error("String_Node_Str",e);
    throw e;
  }
  LOG.debug("String_Node_Str");
  return null;
}
Program: 130773
Project: 130773
Buggy source:
public AckProcessor(Map<String,PeerHandler> quorumSet,int quorumSize){
  this.quorumSet=quorumSet;
  this.quorumSize=quorumSize;
  ft=Executors.newSingleThreadExecutor().submit(this);
}

Fixed version (ground truth):
public AckProcessor(Map<String,PeerHandler> quorumSet,int quorumSize){
  this.quorumSet=quorumSet;
  this.quorumSize=quorumSize;
  ExecutorService es=Executors.newSingleThreadExecutor(DaemonThreadFactory.FACTORY);
  ft=es.submit(this);
  es.shutdown();
}
Program: 130774
Project: 130774
Buggy source:
public CommitProcessor(Log log,StateMachine stateMachine,String serverId){
  this.log=log;
  this.stateMachine=stateMachine;
  this.serverId=serverId;
  ft=Executors.newSingleThreadExecutor().submit(this);
}

Fixed version (ground truth):
public CommitProcessor(Log log,StateMachine stateMachine,String serverId){
  this.log=log;
  this.stateMachine=stateMachine;
  this.serverId=serverId;
  ExecutorService es=Executors.newSingleThreadExecutor(DaemonThreadFactory.FACTORY);
  ft=es.submit(this);
  es.shutdown();
}
Program: 130776
Project: 130776
Buggy source:
/** 
 * Waits for synchronization to followers complete.
 * @throws TimeoutException in case of timeout.
 * @throws InterruptedException in case of interrupt.
 */
void waitNewLeaderAckFromQuorum() throws TimeoutException, InterruptedException, IOException {
  LOG.debug("String_Node_Str");
  int completeCount=0;
  while (completeCount < this.quorumSet.size()) {
    MessageTuple tuple=getExpectedMessage(MessageType.ACK,null);
    ZabMessage.Ack ack=tuple.getMessage().getAck();
    String source=tuple.getSource();
    Zxid zxid=MessageBuilder.fromProtoZxid(ack.getZxid());
    if (zxid.compareTo(this.log.getLatestZxid()) != 0) {
      LOG.error("String_Node_Str",source);
      throw new RuntimeException("String_Node_Str" + "String_Node_Str");
    }
    if (!this.quorumSet.containsKey(source)) {
      LOG.warn("String_Node_Str",source);
      continue;
    }
    completeCount++;
  }
}

Fixed version (ground truth):
/** 
 * Waits for synchronization to followers complete.
 * @throws TimeoutException in case of timeout.
 * @throws InterruptedException in case of interrupt.
 */
void waitNewLeaderAckFromQuorum() throws TimeoutException, InterruptedException, IOException {
  LOG.debug("String_Node_Str");
  int completeCount=0;
  while (completeCount < this.quorumSet.size()) {
    MessageTuple tuple=getExpectedMessage(MessageType.ACK,null);
    ZabMessage.Ack ack=tuple.getMessage().getAck();
    String source=tuple.getSource();
    Zxid zxid=MessageBuilder.fromProtoZxid(ack.getZxid());
    if (zxid.compareTo(this.log.getLatestZxid()) != 0) {
      LOG.error("String_Node_Str",source);
      throw new RuntimeException("String_Node_Str" + "String_Node_Str");
    }
    if (!this.quorumSet.containsKey(source)) {
      LOG.warn("String_Node_Str",source);
      continue;
    }
    this.quorumSet.get(source).setLastAckedZxid(zxid);
    completeCount++;
  }
}
Program: 130777
Project: 130777
Buggy source:
/** 
 * Begins executing follower steps. It returns if any exception is caught, which causes it goes back to election phase.
 */
void follow(){
  try {
    MDC.put("String_Node_Str","String_Node_Str");
    LOG.debug("String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.followerDiscovering(this.electedLeader);
    }
    if (failCallback != null) {
      failCallback.followerDiscovering();
    }
    sendProposedEpoch();
    receiveNewEpoch();
    MDC.put("String_Node_Str","String_Node_Str");
    LOG.debug("String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.followerSynchronizating(getProposedEpochFromFile());
    }
    if (failCallback != null) {
      failCallback.followerSynchronizing();
    }
    waitForSync(this.electedLeader);
    waitNewLeaderMesage();
    MDC.put("String_Node_Str","String_Node_Str");
    this.currentState=ZabState.FOLLOWING;
    LOG.debug("String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.followerBroadcasting(getAckEpochFromFile(),getAllTxns());
    }
    if (failCallback != null) {
      failCallback.followerBroadcasting();
    }
    beginAccepting();
  }
 catch (  InterruptedException|TimeoutException|IOException|RuntimeException e) {
    this.transport.disconnect(this.electedLeader);
    LOG.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Begins executing follower steps. It returns if any exception is caught, which causes it goes back to election phase.
 * @throws InterruptedException
 */
void follow() throws InterruptedException {
  try {
    MDC.put("String_Node_Str","String_Node_Str");
    LOG.debug("String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.followerDiscovering(this.electedLeader);
    }
    if (failCallback != null) {
      failCallback.followerDiscovering();
    }
    sendProposedEpoch();
    receiveNewEpoch();
    MDC.put("String_Node_Str","String_Node_Str");
    LOG.debug("String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.followerSynchronizating(getProposedEpochFromFile());
    }
    if (failCallback != null) {
      failCallback.followerSynchronizing();
    }
    waitForSync(this.electedLeader);
    waitNewLeaderMesage();
    MDC.put("String_Node_Str","String_Node_Str");
    this.currentState=ZabState.FOLLOWING;
    LOG.debug("String_Node_Str");
    if (stateChangeCallback != null) {
      stateChangeCallback.followerBroadcasting(getAckEpochFromFile(),getAllTxns());
    }
    if (failCallback != null) {
      failCallback.followerBroadcasting();
    }
    beginAccepting();
  }
 catch (  InterruptedException|TimeoutException|IOException|RuntimeException e) {
    this.transport.disconnect(this.electedLeader);
    LOG.error("String_Node_Str",e);
    if (e instanceof InterruptedException) {
      throw (InterruptedException)e;
    }
  }
}
Program: 130779
Project: 130779
Buggy source:
/** 
 * Starts main logic of participant.
 */
@Override public Void call() throws Exception {
  LOG.debug("String_Node_Str");
  Election electionAlg=new RoundRobinElection();
  while (true) {
    try {
      MDC.put("String_Node_Str","String_Node_Str");
      MDC.put("String_Node_Str","String_Node_Str");
      this.currentState=ZabState.LOOKING;
      if (this.stateChangeCallback != null) {
        this.stateChangeCallback.electing();
      }
      startLeaderElection(electionAlg);
      waitLeaderElected();
      LOG.debug("String_Node_Str",this.electedLeader);
      if (this.electedLeader.equals(this.config.getServerId())) {
        MDC.put("String_Node_Str","String_Node_Str");
        lead();
      }
 else {
        MDC.put("String_Node_Str","String_Node_Str");
        follow();
      }
    }
 catch (    RuntimeException e) {
      LOG.warn("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Starts main logic of participant.
 */
@Override public Void call() throws Exception {
  LOG.debug("String_Node_Str");
  Election electionAlg=new RoundRobinElection();
  while (true) {
    try {
      MDC.put("String_Node_Str","String_Node_Str");
      MDC.put("String_Node_Str","String_Node_Str");
      this.currentState=ZabState.LOOKING;
      if (this.stateChangeCallback != null) {
        this.stateChangeCallback.electing();
      }
      startLeaderElection(electionAlg);
      waitLeaderElected();
      LOG.debug("String_Node_Str",this.electedLeader);
      if (this.electedLeader.equals(this.config.getServerId())) {
        MDC.put("String_Node_Str","String_Node_Str");
        lead();
      }
 else {
        MDC.put("String_Node_Str","String_Node_Str");
        follow();
      }
    }
 catch (    InterruptedException e) {
      LOG.warn("String_Node_Str",e);
      this.transport.shutdown();
      return null;
    }
catch (    Exception e) {
      LOG.error("String_Node_Str",e);
      return null;
    }
  }
}
Program: 130780
Project: 130780
Buggy source:
void shutdown(){
  this.future.cancel(true);
  this.transport.disconnect(this.serverId);
  LOG.debug("String_Node_Str",this.serverId);
}

Fixed version (ground truth):
void shutdown(){
  if (this.future != null) {
    this.future.cancel(true);
  }
  this.transport.disconnect(this.serverId);
  LOG.debug("String_Node_Str",this.serverId);
}
Program: 130781
Project: 130781
Buggy source:
public PreProcessor(StateMachine stateMachine,Zxid nextZxid,Map<String,PeerHandler> quorumSet){
  this.stateMachine=stateMachine;
  this.nextZxid=nextZxid;
  this.quorumSet=quorumSet;
  ft=Executors.newSingleThreadExecutor().submit(this);
}

Fixed version (ground truth):
public PreProcessor(StateMachine stateMachine,Zxid nextZxid,Map<String,PeerHandler> quorumSet){
  this.stateMachine=stateMachine;
  this.nextZxid=nextZxid;
  this.quorumSet=quorumSet;
  ExecutorService es=Executors.newSingleThreadExecutor(DaemonThreadFactory.FACTORY);
  ft=es.submit(this);
  es.shutdown();
}
Program: 130782
Project: 130782
Buggy source:
/** 
 * Constructs a SyncProposalProcessor object.
 * @param log the log which the transaction will be synchronized to.
 * @param transport used to send acknowledgment.
 */
public SyncProposalProcessor(Log log,Transport transport){
  this.log=log;
  this.transport=transport;
  ft=Executors.newSingleThreadExecutor().submit(this);
}

Fixed version (ground truth):
/** 
 * Constructs a SyncProposalProcessor object.
 * @param log the log which the transaction will be synchronized to.
 * @param transport used to send acknowledgment.
 */
public SyncProposalProcessor(Log log,Transport transport){
  this.log=log;
  this.transport=transport;
  ExecutorService es=Executors.newSingleThreadExecutor(DaemonThreadFactory.FACTORY);
  ft=es.submit(this);
  es.shutdown();
}
Program: 130783
Project: 130783
Buggy source:
public void handshakeCompleted(){
  LOG.debug("String_Node_Str",destination);
  Sender sender=senders.get(destination);
  sender.channel.attr(REMOTE_ID).set(destination);
  sender.channel.pipeline().remove(ReadTimeoutHandler.class);
  sender.channel.pipeline().addLast(new ByteBufferHandler());
  sender.channel.pipeline().addLast(new ErrorHandler());
  sender.start();
}

Fixed version (ground truth):
public void handshakeCompleted(){
}
Program: 130784
Project: 130784
Buggy source:
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  try {
    ByteBuf bb=(ByteBuf)msg;
    LOG.debug("String_Node_Str",bb);
    byte[] buffer=new byte[bb.nioBuffer().remaining()];
    bb.nioBuffer().get(buffer);
    Message message=Message.parseFrom(buffer);
    if (message.getType() != MessageType.HANDSHAKE) {
      LOG.error("String_Node_Str",ctx.channel().remoteAddress(),TextFormat.shortDebugString(message));
      ctx.close();
      return;
    }
    String response=message.getHandshake().getNodeId();
    if (!response.equals(destination)) {
      LOG.error("String_Node_Str",destination,response);
      ctx.close();
      return;
    }
    LOG.debug("String_Node_Str",response);
    ctx.pipeline().remove(this);
    handshakeCompleted();
  }
  finally {
    ReferenceCountUtil.release(msg);
  }
}

Fixed version (ground truth):
@Override public void channelRead(ChannelHandlerContext ctx,Object msg) throws Exception {
  try {
    ByteBuf bb=(ByteBuf)msg;
    LOG.debug("String_Node_Str",bb);
    byte[] buffer=new byte[bb.nioBuffer().remaining()];
    bb.nioBuffer().get(buffer);
    Message message=Message.parseFrom(buffer);
    if (message.getType() != MessageType.HANDSHAKE) {
      LOG.error("String_Node_Str",ctx.channel().remoteAddress(),TextFormat.shortDebugString(message));
      ctx.close();
      return;
    }
    String response=message.getHandshake().getNodeId();
    if (!response.equals(destination)) {
      LOG.error("String_Node_Str",destination,response);
      ctx.close();
      return;
    }
    ctx.pipeline().remove(this);
    handshakeCompleted();
  }
  finally {
    ReferenceCountUtil.release(msg);
  }
}
Program: 130785
Project: 130785
Buggy source:
public Sender(final String source,final String destination){
  this.isServerSide=false;
  this.destination=destination;
  String[] address=destination.split("String_Node_Str",2);
  String host=address[0];
  int port=Integer.parseInt(address[1]);
  LOG.debug("String_Node_Str",host,port);
  Bootstrap b=new Bootstrap();
  b.group(workerGroup);
  b.channel(NioSocketChannel.class);
  b.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,1000);
  b.option(ChannelOption.SO_KEEPALIVE,true);
  b.option(ChannelOption.TCP_NODELAY,true);
  b.handler(new ChannelInitializer<SocketChannel>(){
    @Override public void initChannel(    SocketChannel ch) throws Exception {
      ch.pipeline().addLast(new ReadTimeoutHandler(2));
      ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE,0,4,0,4));
      ch.pipeline().addLast(new ClientHandshakeHandler());
      ch.pipeline().addLast("String_Node_Str",new LengthFieldPrepender(4));
    }
  }
);
  b.connect(host,port).addListener(new ChannelFutureListener(){
    @Override public void operationComplete(    ChannelFuture cfuture){
      if (cfuture.isSuccess()) {
        LOG.debug("String_Node_Str",destination);
        Message msg=MessageBuilder.buildHandshake(source);
        ByteBuffer bb=ByteBuffer.wrap(msg.toByteArray());
        channel=cfuture.channel();
        channel.writeAndFlush(Unpooled.wrappedBuffer(bb));
      }
 else {
        LOG.debug("String_Node_Str",destination,cfuture.cause());
        handshakeFailed();
      }
    }
  }
);
}

Fixed version (ground truth):
public Sender(final String source,final String destination){
  this.isServerSide=false;
  this.destination=destination;
  bootstrap=new Bootstrap();
  bootstrap.group(workerGroup);
  bootstrap.channel(NioSocketChannel.class);
  bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS,1000);
  bootstrap.option(ChannelOption.SO_KEEPALIVE,true);
  bootstrap.option(ChannelOption.TCP_NODELAY,true);
  bootstrap.handler(new ChannelInitializer<SocketChannel>(){
    @Override public void initChannel(    SocketChannel ch) throws Exception {
      ch.pipeline().addLast(new ReadTimeoutHandler(2));
      ch.pipeline().addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE,0,4,0,4));
      ch.pipeline().addLast(new ClientHandshakeHandler());
      ch.pipeline().addLast("String_Node_Str",new LengthFieldPrepender(4));
    }
  }
);
}
Program: 130786
Project: 130786
Buggy source:
@Override public Void call() throws Exception {
  LOG.debug("String_Node_Str",destination);
  try {
    while (true) {
      ByteBuffer buf=requests.take();
      channel.writeAndFlush(Unpooled.wrappedBuffer(buf));
    }
  }
 catch (  InterruptedException ex) {
    LOG.debug("String_Node_Str",destination);
    return null;
  }
catch (  Exception ex) {
    LOG.warn("String_Node_Str",ex);
    throw ex;
  }
 finally {
    channel.close().syncUninterruptibly();
  }
}

Fixed version (ground truth):
@Override public Void call() throws Exception {
  LOG.debug("String_Node_Str",hostPort,destination);
  try {
    while (true) {
      ByteBuffer buf=requests.take();
      channel.writeAndFlush(Unpooled.wrappedBuffer(buf));
    }
  }
 catch (  InterruptedException ex) {
    LOG.debug("String_Node_Str",destination);
    return null;
  }
catch (  Exception ex) {
    LOG.warn("String_Node_Str",ex);
    throw ex;
  }
 finally {
    channel.close().syncUninterruptibly();
  }
}
Program: 130787
Project: 130787
Buggy source:
public void handshakeFailed(){
  if (senders.remove(destination,this)) {
    LOG.debug("String_Node_Str",destination);
    receiver.onDisconnected(destination);
  }
 else   if (!senders.containsKey(destination)) {
    LOG.debug("String_Node_Str",destination);
    receiver.onDisconnected(destination);
  }
}

Fixed version (ground truth):
public void handshakeFailed(){
}
Program: 130788
Project: 130788
Buggy source:
@Override public void send(final String destination,ByteBuffer message){
  if (destination.equals(hostPort)) {
    receiver.onReceived(destination,message);
    return;
  }
  Sender sender=senders.get(destination);
  if (sender != null) {
    sender.requests.add(message);
  }
 else {
    LOG.debug("String_Node_Str",destination);
    sender=new Sender(hostPort,destination);
    sender.requests.add(message);
    senders.putIfAbsent(destination,sender);
  }
}

Fixed version (ground truth):
@Override public void send(final String destination,ByteBuffer message){
  if (destination.equals(hostPort)) {
    receiver.onReceived(destination,message);
    return;
  }
  Sender currentSender=senders.get(destination);
  if (currentSender != null) {
    currentSender.requests.add(message);
  }
 else {
    LOG.debug("String_Node_Str",hostPort,destination);
    Sender newSender=new Sender(hostPort,destination);
    currentSender=senders.putIfAbsent(destination,newSender);
    if (currentSender == null) {
      newSender.requests.add(message);
      newSender.startHandshake();
    }
 else {
      currentSender.requests.add(message);
    }
  }
}