Program: 130760
Project: 130760
Buggy source:
/** 
 * Starts from joining some one who is in cluster..
 * @param peer the id of server who is in cluster.
 * @throws Exception in case something goes wrong.
 */
@Override public void join(String peer) throws Exception {
  LOG.debug("String_Node_Str");
  try {
    LOG.debug("String_Node_Str",peer);
    Message query=MessageBuilder.buildQueryLeader();
    sendMessage(peer,query);
    MessageTuple tuple=getExpectedMessage(MessageType.QUERY_LEADER_REPLY,peer);
    this.electedLeader=tuple.getMessage().getReply().getLeader();
    LOG.debug("String_Node_Str",this.electedLeader);
    Message join=MessageBuilder.buildJoin();
    sendMessage(this.electedLeader,join);
    changePhase(Phase.SYNCHRONIZING);
    waitForSync(this.electedLeader);
    waitForNewLeaderMessage();
    waitForCommitMessage();
    persistence.setProposedEpoch(persistence.getAckEpoch());
    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.getTimeout());
    if (persistence.getLastSeenConfig() == null) {
      throw new JoinFailure("String_Node_Str");
    }
  }
catch (  BackToElectionException e) {
    LOG.debug("String_Node_Str");
    if (persistence.getLastSeenConfig() == null) {
      throw new JoinFailure("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.electedLeader != null) {
      this.transport.clear(this.electedLeader);
    }
  }
}

Fixed version (ground truth):
/** 
 * Starts from joining some one who is in cluster..
 * @param peer the id of server who is in cluster.
 * @throws Exception in case something goes wrong.
 */
@Override public void join(String peer) throws Exception {
  LOG.debug("String_Node_Str");
  try {
    LOG.debug("String_Node_Str",peer);
    Message query=MessageBuilder.buildQueryLeader();
    sendMessage(peer,query);
    MessageTuple tuple=getExpectedMessage(MessageType.QUERY_LEADER_REPLY,peer);
    this.electedLeader=tuple.getMessage().getReply().getLeader();
    LOG.debug("String_Node_Str",this.electedLeader);
    Message sync=MessageBuilder.buildSyncHistory();
    sendMessage(this.electedLeader,sync);
    waitForSync(this.electedLeader);
    Zxid lastZxid=persistence.getLog().getLatestZxid();
    LOG.debug("String_Node_Str",lastZxid);
    Message join=MessageBuilder.buildJoin(lastZxid);
    sendMessage(this.electedLeader,join);
    changePhase(Phase.SYNCHRONIZING);
    waitForSync(this.electedLeader);
    waitForNewLeaderMessage();
    waitForCommitMessage();
    persistence.setProposedEpoch(persistence.getAckEpoch());
    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.getTimeout());
    if (persistence.getLastSeenConfig() == null) {
      throw new JoinFailure("String_Node_Str");
    }
  }
catch (  BackToElectionException e) {
    LOG.debug("String_Node_Str");
    if (persistence.getLastSeenConfig() == null) {
      throw new JoinFailure("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.electedLeader != null) {
      this.transport.clear(this.electedLeader);
    }
  }
}