Program: 130751
Project: 130751
Buggy source:
/** 
 * Entering broadcasting phase, leader broadcasts proposal to followers.
 * @throws InterruptedException if it's interrupted.
 * @throws TimeoutException in case of timeout.
 * @throws IOException in case of IO failure.
 * @throws ExecutionException in case of exception from executors.
 */
void broadcasting() throws TimeoutException, InterruptedException, IOException, ExecutionException {
  Zxid lastZxid=persistence.getLog().getLatestZxid();
  this.establishedEpoch=persistence.getAckEpoch();
  PeerHandler lh=new PeerHandler(serverId,transport,config.getTimeoutMs() / 3);
  lh.setLastAckedZxid(lastZxid);
  lh.startBroadcastingTask();
  quorumSet.put(this.serverId,lh);
  ClusterConfiguration clusterConfig=persistence.getLastSeenConfig();
  PreProcessor preProcessor=new PreProcessor(stateMachine,quorumSet,clusterConfig.clone());
  AckProcessor ackProcessor=new AckProcessor(quorumSet,clusterConfig.clone(),lastZxid);
  SyncProposalProcessor syncProcessor=new SyncProposalProcessor(persistence,transport,SYNC_MAX_BATCH_SIZE);
  CommitProcessor commitProcessor=new CommitProcessor(stateMachine,lastDeliveredZxid,serverId,transport,new HashSet<String>(quorumSet.keySet()),clusterConfig,electedLeader,semPendingReqs);
  SnapshotProcessor snapProcessor=new SnapshotProcessor(stateMachine,persistence);
  stateMachine.leading(new HashSet<String>(quorumSet.keySet()),new HashSet<String>(clusterConfig.getPeers()));
  this.lastCommittedZxid=lastZxid;
  this.lastProposedZxid=lastZxid;
  this.lastAckedZxid=lastZxid;
  try {
    while (this.quorumSet.size() >= clusterConfig.getQuorumSize()) {
      MessageTuple tuple=getMessage();
      Message msg=tuple.getMessage();
      String source=tuple.getServerId();
      if (msg.getType() == MessageType.PROPOSED_EPOCH) {
        LOG.debug("String_Node_Str",source);
        ClusterConfiguration cnf=persistence.getLastSeenConfig();
        if (!cnf.contains(source)) {
          LOG.warn("String_Node_Str" + "String_Node_Str",source);
          continue;
        }
        int syncTimeoutMs=msg.getProposedEpoch().getSyncTimeout();
        if (syncTimeoutMs > getSyncTimeoutMs()) {
          setSyncTimeoutMs(syncTimeoutMs);
        }
        Message newEpoch=MessageBuilder.buildNewEpochMessage(establishedEpoch,getSyncTimeoutMs());
        sendMessage(source,newEpoch);
      }
 else       if (msg.getType() == MessageType.ACK_EPOCH) {
        LOG.debug("String_Node_Str",source);
        tuple.setZxid(lastProposedZxid);
        onAckEpoch(tuple,preProcessor,ackProcessor,commitProcessor);
      }
 else       if (msg.getType() == MessageType.QUERY_LEADER) {
        LOG.debug("String_Node_Str",source);
        Message reply=MessageBuilder.buildQueryReply(this.serverId);
        sendMessage(source,reply);
      }
 else       if (msg.getType() == MessageType.SYNC_HISTORY) {
        onSyncHistory(tuple);
      }
 else {
        if (!this.quorumSet.containsKey(source)) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("String_Node_Str",TextFormat.shortDebugString(msg),source);
          }
          continue;
        }
        if (msg.getType() != MessageType.HEARTBEAT && LOG.isDebugEnabled()) {
          LOG.debug("String_Node_Str",TextFormat.shortDebugString(msg),source);
        }
        if (msg.getType() == MessageType.ACK) {
          onAck(tuple,ackProcessor);
        }
 else         if (msg.getType() == MessageType.REQUEST) {
          Zxid proposedZxid=getNextProposedZxid();
          quorumSet.get(source).setLastProposedZxid(proposedZxid);
          tuple.setZxid(proposedZxid);
          preProcessor.processRequest(tuple);
        }
 else         if (msg.getType() == MessageType.FLUSH_REQ) {
          onFlushReq(tuple);
        }
 else         if (msg.getType() == MessageType.FLUSH) {
          onFlush(tuple,commitProcessor);
        }
 else         if (msg.getType() == MessageType.HEARTBEAT) {
          LOG.trace("String_Node_Str",source);
        }
 else         if (msg.getType() == MessageType.PROPOSAL) {
          syncProcessor.processRequest(tuple);
          commitProcessor.processRequest(tuple);
        }
 else         if (msg.getType() == MessageType.COMMIT) {
          onCommit(tuple,commitProcessor);
        }
 else         if (msg.getType() == MessageType.DISCONNECTED) {
          onDisconnected(tuple,preProcessor,ackProcessor,commitProcessor);
        }
 else         if (msg.getType() == MessageType.REMOVE) {
          if (pendingCopZxid != null) {
            LOG.warn("String_Node_Str");
            continue;
          }
          pendingCopZxid=getNextProposedZxid();
          tuple.setZxid(pendingCopZxid);
          onRemove(tuple,preProcessor,ackProcessor,clusterConfig);
        }
 else         if (msg.getType() == MessageType.DELIVERED) {
          onDelivered(msg,snapProcessor);
        }
 else         if (msg.getType() == MessageType.JOIN) {
          LOG.debug("String_Node_Str",source);
          if (pendingCopZxid != null) {
            LOG.warn("String_Node_Str");
            continue;
          }
          pendingCopZxid=getNextProposedZxid();
          tuple.setZxid(pendingCopZxid);
          onJoin(tuple,preProcessor,ackProcessor,commitProcessor,clusterConfig);
        }
 else {
          if (LOG.isWarnEnabled()) {
            LOG.warn("String_Node_Str",TextFormat.shortDebugString(msg),source);
          }
        }
        PeerHandler ph=quorumSet.get(source);
        if (ph != null) {
          ph.updateHeartbeatTime();
        }
        checkFollowerLiveness();
      }
    }
    LOG.debug("String_Node_Str" + "String_Node_Str",getQuorumSize());
  }
  finally {
    ackProcessor.shutdown();
    preProcessor.shutdown();
    commitProcessor.shutdown();
    syncProcessor.shutdown();
    snapProcessor.shutdown();
    this.lastDeliveredZxid=commitProcessor.getLastDeliveredZxid();
    this.participantState.updateLastDeliveredZxid(this.lastDeliveredZxid);
  }
}

Fixed version (ground truth):
/** 
 * Entering broadcasting phase, leader broadcasts proposal to followers.
 * @throws InterruptedException if it's interrupted.
 * @throws TimeoutException in case of timeout.
 * @throws IOException in case of IO failure.
 * @throws ExecutionException in case of exception from executors.
 */
void broadcasting() throws TimeoutException, InterruptedException, IOException, ExecutionException {
  Zxid lastZxid=persistence.getLog().getLatestZxid();
  this.establishedEpoch=persistence.getAckEpoch();
  PeerHandler lh=new PeerHandler(serverId,transport,config.getTimeoutMs() / 3);
  lh.setLastAckedZxid(lastZxid);
  lh.startBroadcastingTask();
  quorumSet.put(this.serverId,lh);
  ClusterConfiguration clusterConfig=persistence.getLastSeenConfig();
  PreProcessor preProcessor=new PreProcessor(stateMachine,quorumSet,clusterConfig.clone());
  AckProcessor ackProcessor=new AckProcessor(quorumSet,clusterConfig.clone(),lastZxid);
  SyncProposalProcessor syncProcessor=new SyncProposalProcessor(persistence,transport,SYNC_MAX_BATCH_SIZE);
  CommitProcessor commitProcessor=new CommitProcessor(stateMachine,lastDeliveredZxid,serverId,transport,new HashSet<String>(quorumSet.keySet()),clusterConfig,electedLeader,semPendingReqs);
  SnapshotProcessor snapProcessor=new SnapshotProcessor(stateMachine,persistence);
  stateMachine.leading(new HashSet<String>(quorumSet.keySet()),new HashSet<String>(clusterConfig.getPeers()));
  this.lastCommittedZxid=lastZxid;
  this.lastProposedZxid=lastZxid;
  this.lastAckedZxid=lastZxid;
  try {
    while (this.quorumSet.size() >= clusterConfig.getQuorumSize()) {
      MessageTuple tuple=getMessage();
      Message msg=tuple.getMessage();
      String source=tuple.getServerId();
      if (msg.getType() == MessageType.PROPOSED_EPOCH) {
        LOG.debug("String_Node_Str",source);
        ClusterConfiguration cnf=persistence.getLastSeenConfig();
        if (!cnf.contains(source)) {
          LOG.warn("String_Node_Str" + "String_Node_Str",source);
          continue;
        }
        int syncTimeoutMs=msg.getProposedEpoch().getSyncTimeout();
        if (syncTimeoutMs > getSyncTimeoutMs()) {
          setSyncTimeoutMs(syncTimeoutMs);
        }
        Message newEpoch=MessageBuilder.buildNewEpochMessage(establishedEpoch,getSyncTimeoutMs());
        sendMessage(source,newEpoch);
      }
 else       if (msg.getType() == MessageType.ACK_EPOCH) {
        LOG.debug("String_Node_Str",source);
        tuple.setZxid(lastProposedZxid);
        onAckEpoch(tuple,preProcessor,ackProcessor,commitProcessor);
      }
 else       if (msg.getType() == MessageType.QUERY_LEADER) {
        LOG.debug("String_Node_Str",source);
        Message reply=MessageBuilder.buildQueryReply(this.serverId);
        sendMessage(source,reply);
      }
 else       if (msg.getType() == MessageType.SYNC_HISTORY) {
        onSyncHistory(tuple);
      }
 else       if (msg.getType() == MessageType.ELECTION_INFO) {
        this.election.reply(tuple);
      }
 else {
        if (!this.quorumSet.containsKey(source)) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("String_Node_Str",TextFormat.shortDebugString(msg),source);
          }
          continue;
        }
        if (msg.getType() != MessageType.HEARTBEAT && LOG.isDebugEnabled()) {
          LOG.debug("String_Node_Str",TextFormat.shortDebugString(msg),source);
        }
        if (msg.getType() == MessageType.ACK) {
          onAck(tuple,ackProcessor);
        }
 else         if (msg.getType() == MessageType.REQUEST) {
          Zxid proposedZxid=getNextProposedZxid();
          quorumSet.get(source).setLastProposedZxid(proposedZxid);
          tuple.setZxid(proposedZxid);
          preProcessor.processRequest(tuple);
        }
 else         if (msg.getType() == MessageType.FLUSH_REQ) {
          onFlushReq(tuple);
        }
 else         if (msg.getType() == MessageType.FLUSH) {
          onFlush(tuple,commitProcessor);
        }
 else         if (msg.getType() == MessageType.HEARTBEAT) {
          LOG.trace("String_Node_Str",source);
        }
 else         if (msg.getType() == MessageType.PROPOSAL) {
          syncProcessor.processRequest(tuple);
          commitProcessor.processRequest(tuple);
        }
 else         if (msg.getType() == MessageType.COMMIT) {
          onCommit(tuple,commitProcessor);
        }
 else         if (msg.getType() == MessageType.DISCONNECTED) {
          onDisconnected(tuple,preProcessor,ackProcessor,commitProcessor);
        }
 else         if (msg.getType() == MessageType.REMOVE) {
          if (pendingCopZxid != null) {
            LOG.warn("String_Node_Str");
            continue;
          }
          pendingCopZxid=getNextProposedZxid();
          tuple.setZxid(pendingCopZxid);
          onRemove(tuple,preProcessor,ackProcessor,clusterConfig);
        }
 else         if (msg.getType() == MessageType.DELIVERED) {
          onDelivered(msg,snapProcessor);
        }
 else         if (msg.getType() == MessageType.JOIN) {
          LOG.debug("String_Node_Str",source);
          if (pendingCopZxid != null) {
            LOG.warn("String_Node_Str");
            continue;
          }
          pendingCopZxid=getNextProposedZxid();
          tuple.setZxid(pendingCopZxid);
          onJoin(tuple,preProcessor,ackProcessor,commitProcessor,clusterConfig);
        }
 else {
          if (LOG.isWarnEnabled()) {
            LOG.warn("String_Node_Str",TextFormat.shortDebugString(msg),source);
          }
        }
        PeerHandler ph=quorumSet.get(source);
        if (ph != null) {
          ph.updateHeartbeatTime();
        }
        checkFollowerLiveness();
      }
    }
    LOG.debug("String_Node_Str" + "String_Node_Str",getQuorumSize());
  }
  finally {
    ackProcessor.shutdown();
    preProcessor.shutdown();
    commitProcessor.shutdown();
    syncProcessor.shutdown();
    snapProcessor.shutdown();
    this.lastDeliveredZxid=commitProcessor.getLastDeliveredZxid();
    this.participantState.updateLastDeliveredZxid(this.lastDeliveredZxid);
  }
}