nus-yam/ex-repair huggingface dataset:
Program: 18062
Project: 18062
Buggy source:
public void run(){
  logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
  Storage storage=paxos.getStorage();
  if (storage.getEpoch()[sender] > recovery.getEpoch()) {
    logger.info("String_Node_Str",sender,recovery);
    return;
  }
  if (paxos.getLeaderId() == sender) {
    paxos.getProposer().prepareNextView();
    onMessageReceived(recovery,sender);
    return;
  }
  if (paxos.isLeader() && paxos.getProposer().getState() == ProposerState.PREPARING) {
    paxos.getProposer().executeOnPrepared(new Proposer.Task(){
      public void onPrepared(){
        onMessageReceived(recovery,sender);
      }
      public void onFailedToPrepare(){
        onMessageReceived(recovery,sender);
      }
    }
);
    return;
  }
  storage.updateEpoch(recovery.getEpoch(),sender);
  RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getEpoch(),storage.getLog().getNextId());
  paxos.getNetwork().sendMessage(answer,sender);
}

Fixed version (ground truth):
public void run(){
  Storage storage=paxos.getStorage();
  if (storage.getEpoch()[sender] > recovery.getEpoch()) {
    logger.info("String_Node_Str",sender,recovery);
    return;
  }
  if (paxos.getLeaderId() == sender) {
    logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
    paxos.getProposer().prepareNextView();
    onMessageReceived(recovery,sender);
    return;
  }
  logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
  if (paxos.isLeader() && paxos.getProposer().getState() == ProposerState.PREPARING) {
    paxos.getProposer().executeOnPrepared(new Proposer.Task(){
      public void onPrepared(){
        onMessageReceived(recovery,sender);
      }
      public void onFailedToPrepare(){
        onMessageReceived(recovery,sender);
      }
    }
);
    return;
  }
  storage.updateEpoch(recovery.getEpoch(),sender);
  RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getEpoch(),storage.getLog().getNextId());
  paxos.getNetwork().sendMessage(answer,sender);
}
Program: 18063
Project: 18063
Buggy source:
public void onMessageReceived(Message message,final int sender){
  final Recovery recovery=(Recovery)message;
  paxos.getDispatcher().submit(new Runnable(){
    public void run(){
      logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
      Storage storage=paxos.getStorage();
      if (storage.getEpoch()[sender] > recovery.getEpoch()) {
        logger.info("String_Node_Str",sender,recovery);
        return;
      }
      if (paxos.getLeaderId() == sender) {
        paxos.getProposer().prepareNextView();
        onMessageReceived(recovery,sender);
        return;
      }
      if (paxos.isLeader() && paxos.getProposer().getState() == ProposerState.PREPARING) {
        paxos.getProposer().executeOnPrepared(new Proposer.Task(){
          public void onPrepared(){
            onMessageReceived(recovery,sender);
          }
          public void onFailedToPrepare(){
            onMessageReceived(recovery,sender);
          }
        }
);
        return;
      }
      storage.updateEpoch(recovery.getEpoch(),sender);
      RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getEpoch(),storage.getLog().getNextId());
      paxos.getNetwork().sendMessage(answer,sender);
    }
  }
);
}

Fixed version (ground truth):
public void onMessageReceived(Message message,final int sender){
  final Recovery recovery=(Recovery)message;
  paxos.getDispatcher().submit(new Runnable(){
    public void run(){
      Storage storage=paxos.getStorage();
      if (storage.getEpoch()[sender] > recovery.getEpoch()) {
        logger.info("String_Node_Str",sender,recovery);
        return;
      }
      if (paxos.getLeaderId() == sender) {
        logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
        paxos.getProposer().prepareNextView();
        onMessageReceived(recovery,sender);
        return;
      }
      logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
      if (paxos.isLeader() && paxos.getProposer().getState() == ProposerState.PREPARING) {
        paxos.getProposer().executeOnPrepared(new Proposer.Task(){
          public void onPrepared(){
            onMessageReceived(recovery,sender);
          }
          public void onFailedToPrepare(){
            onMessageReceived(recovery,sender);
          }
        }
);
        return;
      }
      storage.updateEpoch(recovery.getEpoch(),sender);
      RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getEpoch(),storage.getLog().getNextId());
      paxos.getNetwork().sendMessage(answer,sender);
    }
  }
);
}
Program: 18064
Project: 18064
Buggy source:
public void run(){
  logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
  Storage storage=paxos.getStorage();
  Proposer proposer=paxos.getProposer();
  if (paxos.getLeaderId() == sender || recovery.getView() >= storage.getView()) {
    if (proposer.getState() != ProposerState.INACTIVE)     proposer.stopProposer();
    proposer.prepareNextView();
    onMessageReceived(recovery,sender);
    return;
  }
  if (paxos.isLeader() && proposer.getState() == ProposerState.PREPARING) {
    proposer.executeOnPrepared(new Proposer.Task(){
      public void onPrepared(){
        onMessageReceived(recovery,sender);
      }
      public void onFailedToPrepare(){
        onMessageReceived(recovery,sender);
      }
    }
);
    return;
  }
  RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getLog().getNextId());
  paxos.getNetwork().sendMessage(answer,sender);
}

Fixed version (ground truth):
public void run(){
  Storage storage=paxos.getStorage();
  Proposer proposer=paxos.getProposer();
  if (paxos.getLeaderId() == sender || recovery.getView() >= storage.getView()) {
    logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
    if (proposer.getState() != ProposerState.INACTIVE)     proposer.stopProposer();
    proposer.prepareNextView();
    onMessageReceived(recovery,sender);
    return;
  }
  if (paxos.isLeader() && proposer.getState() == ProposerState.PREPARING) {
    logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
    proposer.executeOnPrepared(new Proposer.Task(){
      public void onPrepared(){
        onMessageReceived(recovery,sender);
      }
      public void onFailedToPrepare(){
        onMessageReceived(recovery,sender);
      }
    }
);
    return;
  }
  logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
  RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getLog().getNextId());
  paxos.getNetwork().sendMessage(answer,sender);
}
Program: 18065
Project: 18065
Buggy source:
public void onMessageReceived(Message msg,final int sender){
  final Recovery recovery=(Recovery)msg;
  paxos.getDispatcher().submit(new Runnable(){
    public void run(){
      logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
      Storage storage=paxos.getStorage();
      Proposer proposer=paxos.getProposer();
      if (paxos.getLeaderId() == sender || recovery.getView() >= storage.getView()) {
        if (proposer.getState() != ProposerState.INACTIVE)         proposer.stopProposer();
        proposer.prepareNextView();
        onMessageReceived(recovery,sender);
        return;
      }
      if (paxos.isLeader() && proposer.getState() == ProposerState.PREPARING) {
        proposer.executeOnPrepared(new Proposer.Task(){
          public void onPrepared(){
            onMessageReceived(recovery,sender);
          }
          public void onFailedToPrepare(){
            onMessageReceived(recovery,sender);
          }
        }
);
        return;
      }
      RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getLog().getNextId());
      paxos.getNetwork().sendMessage(answer,sender);
    }
  }
);
}

Fixed version (ground truth):
public void onMessageReceived(Message msg,final int sender){
  final Recovery recovery=(Recovery)msg;
  paxos.getDispatcher().submit(new Runnable(){
    public void run(){
      Storage storage=paxos.getStorage();
      Proposer proposer=paxos.getProposer();
      if (paxos.getLeaderId() == sender || recovery.getView() >= storage.getView()) {
        logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
        if (proposer.getState() != ProposerState.INACTIVE)         proposer.stopProposer();
        proposer.prepareNextView();
        onMessageReceived(recovery,sender);
        return;
      }
      if (paxos.isLeader() && proposer.getState() == ProposerState.PREPARING) {
        logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
        proposer.executeOnPrepared(new Proposer.Task(){
          public void onPrepared(){
            onMessageReceived(recovery,sender);
          }
          public void onFailedToPrepare(){
            onMessageReceived(recovery,sender);
          }
        }
);
        return;
      }
      logger.info(processDescriptor.logMark_Benchmark,"String_Node_Str",recovery);
      RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getLog().getNextId());
      paxos.getNetwork().sendMessage(answer,sender);
    }
  }
);
}
Program: 18066
Project: 18066
Buggy source:
private void finished(){
  ScheduledFuture<?> sf=taskToFuture.remove(this);
  sf.cancel(false);
  dispatcher.remove(this);
  dispatcher.purge();
  if (hook != null)   hook.hook();
}

Fixed version (ground truth):
private void finished(){
  ScheduledFuture<?> sf=taskToFuture.remove(this);
  if (sf != null)   sf.cancel(false);
  dispatcher.remove(this);
  dispatcher.purge();
  if (hook != null)   hook.hook();
}
Program: 18067
Project: 18067
Buggy source:
public ClientThread() throws IOException {
  setDaemon(true);
  client=new Client();
  sends=new ArrayBlockingQueue<Integer>(128);
  request=new byte[requestSize];
}

Fixed version (ground truth):
public ClientThread() throws IOException {
  setDaemon(true);
  client=new Client(configuration);
  sends=new ArrayBlockingQueue<Integer>(128);
  request=new byte[requestSize];
}
Program: 18068
Project: 18068
Buggy source:
public GenericMultiClient(int requestSize,boolean randomRequests){
  this.requestSize=requestSize;
  this.randomRequests=randomRequests;
}

Fixed version (ground truth):
public GenericMultiClient(int requestSize,boolean randomRequests) throws IOException {
  this.configuration=new Configuration();
  this.requestSize=requestSize;
  this.randomRequests=randomRequests;
}
Program: 18069
Project: 18069
Buggy source:
/** 
 * Creates a new TCP connection to specified replica.
 * @param network - related <code>TcpNetwork</code>.
 * @param replica - replica to connect to.
 * @param peerId - ID of the replica on the other end of connection
 * @param active - initiates connection if true; waits for remote connectionotherwise.
 */
public TcpConnection(TcpNetwork network,final PID replica,int peerId,boolean active){
  this.network=network;
  this.replica=replica;
  this.peerId=peerId;
  this.active=active;
  logger.info("String_Node_Str",replica,active);
  receiverThread=new Thread(new ReceiverThread(),"String_Node_Str" + replica.getId());
  senderThread=new Thread(new Sender(),"String_Node_Str" + replica.getId());
  receiverThread.setUncaughtExceptionHandler(new KillOnExceptionHandler());
  senderThread.setUncaughtExceptionHandler(new KillOnExceptionHandler());
  receiverThread.setDaemon(true);
  senderThread.setDaemon(true);
}

Fixed version (ground truth):
/** 
 * Creates a new TCP connection to specified replica.
 * @param network - related <code>TcpNetwork</code>.
 * @param replica - replica to connect to.
 * @param peerId - ID of the replica on the other end of connection
 * @param active - initiates connection if true; waits for remote connectionotherwise.
 */
public TcpConnection(TcpNetwork network,final PID replica,int peerId,boolean active){
  this.network=network;
  this.replica=replica;
  this.peerId=peerId;
  this.active=active;
  logger.info("String_Node_Str",replica,active);
  receiverThread=new Thread(new ReceiverThread(),"String_Node_Str" + replica.getId());
  senderThread=new Thread(new Sender(),"String_Node_Str" + replica.getId());
  receiverThread.setUncaughtExceptionHandler(new KillOnExceptionHandler());
  senderThread.setUncaughtExceptionHandler(new KillOnExceptionHandler());
  receiverThread.setDaemon(true);
  senderThread.setDaemon(true);
  senderThread.setPriority(Thread.MAX_PRIORITY);
}
Program: 18070
Project: 18070
Buggy source:
/** 
 * Sends specified binary packet using underlying TCP connection.
 * @param message - binary packet to send
 * @return true if sending message was successful
 */
public void send(byte[] message){
  try {
    if (connected) {
      long start=System.currentTimeMillis();
      sendQueue.put(message);
      int delta=(int)(System.currentTimeMillis() - start);
      if (delta > 10) {
        logger.warn("String_Node_Str",delta);
      }
    }
 else {
      while (!sendQueue.offer(message)) {
        sendQueue.poll();
      }
    }
  }
 catch (  InterruptedException e) {
    if (!closing) {
      throw new RuntimeException("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sends specified binary packet using underlying TCP connection.
 * @param message - binary packet to send
 * @return true if sending message was successful
 */
public void send(byte[] message){
  if (connected) {
    if (sendQueue.remainingCapacity() == 0)     Thread.yield();
    while (!sendQueue.offer(message)) {
      byte[] discarded=sendQueue.poll();
      logger.warn("String_Node_Str",discarded,message);
    }
  }
 else {
    while (!sendQueue.offer(message)) {
      sendQueue.poll();
    }
  }
}
Program: 18071
Project: 18071
Buggy source:
private void onClientRequest(ClientRequest request,ClientProxy client) throws InterruptedException {
  RequestId reqId=request.getRequestId();
  Reply lastReply=lastReplies.get(reqId.getClientId());
  boolean newRequest=lastReply == null || reqId.getSeqNumber() > lastReply.getRequestId().getSeqNumber();
  if (newRequest) {
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + request);
    }
    if (USE_FLOW_CONTROL)     if (!pendingClientProxies.containsKey(reqId))     pendingRequestsSem.acquire();
    if (client != null)     pendingClientProxies.put(reqId,client);
 else     if (USE_FLOW_CONTROL)     pendingClientProxies.put(reqId,NULL_CLIENT_PROXY);
    if (!processDescriptor.indirectConsensus && paxos.isLeader()) {
      paxos.enqueueRequest(request);
    }
 else {
      cBatcher.enqueueRequest(request);
    }
  }
 else {
    if (client == null)     return;
    if (lastReply.getRequestId().equals(reqId)) {
      client.send(new ClientReply(Result.OK,lastReply.toByteArray()));
    }
 else {
      String errorMsg="String_Node_Str" + request.getRequestId() + "String_Node_Str"+ lastReply.getRequestId();
      logger.warning(errorMsg);
      client.send(new ClientReply(Result.NACK,errorMsg.getBytes()));
    }
  }
}

Fixed version (ground truth):
private void onClientRequest(ClientRequest request,ClientProxy client) throws InterruptedException {
  RequestId reqId=request.getRequestId();
  Reply lastReply=lastReplies.get(reqId.getClientId());
  boolean newRequest=lastReply == null || reqId.getSeqNumber() > lastReply.getRequestId().getSeqNumber();
  if (newRequest) {
    if (logger.isLoggable(Level.FINE)) {
      logger.fine("String_Node_Str" + request);
    }
    if (USE_FLOW_CONTROL)     if (!pendingClientProxies.containsKey(reqId))     pendingRequestsSem.acquire();
    if (client != null)     pendingClientProxies.put(reqId,client);
 else     if (USE_FLOW_CONTROL)     pendingClientProxies.put(reqId,NULL_CLIENT_PROXY);
    if (paxos.isLeader()) {
      paxos.enqueueRequest(request);
    }
 else {
      cBatcher.enqueueRequest(request);
    }
  }
 else {
    if (client == null)     return;
    if (lastReply.getRequestId().equals(reqId)) {
      client.send(new ClientReply(Result.OK,lastReply.toByteArray()));
    }
 else {
      String errorMsg="String_Node_Str" + request.getRequestId() + "String_Node_Str"+ lastReply.getRequestId();
      logger.warning(errorMsg);
      client.send(new ClientReply(Result.NACK,errorMsg.getBytes()));
    }
  }
}
Program: 18072
Project: 18072
Buggy source:
/** 
 * Scheadules a task to be executed as soon as the proposer is prepared
 */
public void executeOnPrepared(final Runnable task);

Fixed version (ground truth):
/** 
 * Schedules a task to be executed as soon as the proposer is prepared
 */
public void executeOnPrepared(final Task task);
Program: 18073
Project: 18073
Buggy source:
public void executeOnPrepared(final Runnable task){
}

Fixed version (ground truth):
public void executeOnPrepared(final Task task){
}
Program: 18074
Project: 18074
Buggy source:
public void run(){
  onMessageReceived(recovery,sender);
}

Fixed version (ground truth):
@Override public void run(){
  onMessageReceived(recovery,sender);
}
Program: 18075
Project: 18075
Buggy source:
public void onMessageReceived(Message msg,final int sender){
  final Recovery recovery=(Recovery)msg;
  paxos.getDispatcher().submit(new Runnable(){
    public void run(){
      logger.info("String_Node_Str" + recovery);
      if (paxos.getLeaderId() == sender) {
        paxos.suspect(paxos.getLeaderId());
        return;
      }
      if (paxos.isLeader() && paxos.getProposer().getState() == ProposerState.PREPARING) {
        paxos.getProposer().executeOnPrepared(new Runnable(){
          public void run(){
            onMessageReceived(recovery,sender);
          }
        }
);
        return;
      }
      Storage storage=paxos.getStorage();
      if (recovery.getView() >= storage.getView()) {
        int newView=recovery.getView() + 1;
        if (processDescriptor.isLocalProcessLeader(newView)) {
          newView++;
        }
        paxos.advanceView(newView);
        paxos.suspect(newView);
        onMessageReceived(recovery,sender);
        return;
      }
      RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getLog().getNextId());
      paxos.getNetwork().sendMessage(answer,sender);
    }
  }
);
}

Fixed version (ground truth):
public void onMessageReceived(Message msg,final int sender){
  final Recovery recovery=(Recovery)msg;
  paxos.getDispatcher().submit(new Runnable(){
    public void run(){
      logger.info("String_Node_Str" + recovery);
      if (paxos.getLeaderId() == sender) {
        paxos.suspect(paxos.getLeaderId());
        paxos.getDispatcher().schedule(new Runnable(){
          @Override public void run(){
            onMessageReceived(recovery,sender);
          }
        }
,1,TimeUnit.MILLISECONDS);
        return;
      }
      if (paxos.isLeader() && paxos.getProposer().getState() == ProposerState.PREPARING) {
        paxos.getProposer().executeOnPrepared(new Proposer.Task(){
          public void onPrepared(){
            onMessageReceived(recovery,sender);
          }
          public void onFailedToPrepare(){
            onMessageReceived(recovery,sender);
          }
        }
);
        return;
      }
      Storage storage=paxos.getStorage();
      if (recovery.getView() >= storage.getView()) {
        int newView=recovery.getView() + 1;
        if (processDescriptor.isLocalProcessLeader(newView)) {
          newView++;
        }
        paxos.advanceView(newView);
        paxos.suspect(newView);
        onMessageReceived(recovery,sender);
        return;
      }
      RecoveryAnswer answer=new RecoveryAnswer(storage.getView(),storage.getLog().getNextId());
      paxos.getNetwork().sendMessage(answer,sender);
    }
  }
);
}
Program: 18076
Project: 18076
Buggy source:
public InternalClient(SingleThreadDispatcher replicaDispatcher,ClientRequestManager clientRequestManager){
  this.replicaDispatcher=replicaDispatcher;
  this.clientRequestManager=clientRequestManager;
}

Fixed version (ground truth):
public InternalClient(SingleThreadDispatcher replicaDispatcher,ClientRequestManager clientRequestManager){
  internalClientDispatcher=new SingleThreadDispatcher("String_Node_Str");
  this.clientRequestManager=clientRequestManager;
}
Program: 18077
Project: 18077
Buggy source:
/** 
 * @throws InterruptedException in case the replica has been interruptedwhile waiting to put the request on propose queue
 */
public void executeNonFifo(byte[] request){
  RequestId reqId=freeIds.poll();
  if (reqId == null)   reqId=new RequestId(NioClientProxy.idGenerator.next(),0);
  ClientRequest cr=new ClientRequest(reqId,request);
  ClientCommand cc=new ClientCommand(CommandType.REQUEST,cr);
  InternalClientProxy icp=new InternalClientProxy(reqId);
  RequestRepeater rr=new RequestRepeater(cc,icp);
  icp.setRepeater(rr,replicaDispatcher.schedule(rr,(long)(3 * averageRequestTime.get()),TimeUnit.MILLISECONDS));
  if (logger.isLoggable(Level.FINE))   logger.fine("String_Node_Str" + reqId);
  clientRequestManager.dispatchOnClientRequest(cc,icp);
}

Fixed version (ground truth):
/** 
 * @throws InterruptedException in case the replica has been interruptedwhile waiting to put the request on propose queue
 */
public void executeNonFifo(final byte[] request){
  internalClientDispatcher.execute(new Runnable(){
    public void run(){
      executeNonFifoInternal(request);
    }
  }
);
}
Program: 18078
Project: 18078
Buggy source:
public void run(){
  if (!shouldRepeat())   return;
  if (logger.isLoggable(Level.FINE))   logger.fine("String_Node_Str" + cc.getRequest().getRequestId());
  icp.setRepeater(this,replicaDispatcher.schedule(this,(long)(3 * averageRequestTime.get()),TimeUnit.MILLISECONDS));
  clientRequestManager.dispatchOnClientRequest(cc,icp);
}

Fixed version (ground truth):
public void run(){
  internalClientDispatcher.checkInDispatcher();
  if (!shouldRepeat())   return;
  if (logger.isLoggable(Level.FINER))   logger.finer("String_Node_Str" + cc.getRequest().getRequestId());
  icp.sf=internalClientDispatcher.schedule(this,(long)(3 * averageRequestTime.get()),TimeUnit.MILLISECONDS);
  clientRequestManager.dispatchOnClientRequest(cc,icp);
}
Program: 18079
Project: 18079
Buggy source:
/** 
 * Called upon generating the answer for previous request 
 */
public void send(ClientReply clientReply){
  if (logger.isLoggable(Level.FINE))   logger.fine("String_Node_Str" + cliId + "String_Node_Str"+ seqNo);
  averageRequestTime.add(System.currentTimeMillis() - startTime);
  freeIds.add(new RequestId(cliId,seqNo + 1));
  replicaDispatcher.remove(repeater);
  sf.cancel(false);
}

Fixed version (ground truth):
/** 
 * Called upon generating the answer for previous request 
 */
public void send(ClientReply clientReply){
}
Program: 18080
Project: 18080
Buggy source:
protected final void onValueChange(){
  for (  ClientBatchID cbid : Batcher.unpack(value)) {
    ClientBatchStore.instance.associateWithInstance(cbid);
  }
}

Fixed version (ground truth):
protected final void onValueChange(){
  if (value == null)   return;
  for (  ClientBatchID cbid : Batcher.unpack(value)) {
    ClientBatchStore.instance.associateWithInstance(cbid);
  }
}
Program: 18081
Project: 18081
Buggy source:
/** 
 * Sets new value holding by this instance. Each value has view in which it is valid, so it has to be set here also.
 * @param view - the view number in which value is valid
 * @param value - the value which was accepted by this instance
 */
private void setValue(int view,byte[] value){
}

Fixed version (ground truth):
/** 
 * Sets new value holding by this instance. Each value has view in which it is valid, so it has to be set here also.
 * @param view - the view number in which value is valid
 * @param value - the value which was accepted by this instance
 */
protected void setValue(int view,byte[] value){
}
Program: 18082
Project: 18082
Buggy source:
/** 
 * Handles exceptions thrown by the executed tasks. Kills the process on exception as tasks shouldn't throw exceptions under normal conditions.
 */
protected void afterExecute(Runnable r,Throwable t){
}

Fixed version (ground truth):
/** 
 * Handles exceptions thrown by the executed tasks. Kills the process on exception as tasks shouldn't throw exceptions under normal conditions.
 */
protected void afterExecute(Runnable r,Throwable t){
  super.afterExecute(r,t);
  if (t == null && r instanceof FutureTask<?>) {
    FutureTask<?> fTask=(FutureTask<?>)r;
    if (!fTask.isDone()) {
      return;
    }
 else {
      try {
        fTask.get(0,TimeUnit.MILLISECONDS);
      }
 catch (      CancellationException ce) {
        logger.info("String_Node_Str" + r);
      }
catch (      ExecutionException ee) {
        t=ee.getCause();
      }
catch (      InterruptedException ie) {
        Thread.currentThread().interrupt();
      }
catch (      TimeoutException e) {
        logger.log(Level.SEVERE,"String_Node_Str" + r,e);
      }
    }
  }
  if (t != null) {
    if (printErrorsToConsole) {
      t.printStackTrace();
      printErrorsToConsole=false;
    }
    logger.log(Level.SEVERE,"String_Node_Str",t);
  }
}
Program: 18083
Project: 18083
Buggy source:
public void start(){
  latch.countDown();
}

Fixed version (ground truth):
public void start(){
}
Program: 18084
Project: 18084
Buggy source:
public void startProposing(){
  final Set<ClientBatchID> decided=new HashSet<ClientBatchID>();
  final Set<ClientBatchID> known=new HashSet<ClientBatchID>();
  Storage storage=paxos.getStorage();
  if (logger.isLoggable(Level.FINE)) {
    logger.fine("String_Node_Str" + storage.getFirstUncommitted() + "String_Node_Str"+ storage.getLog().getNextId());
  }
  for (int i=storage.getFirstUncommitted(); i < storage.getLog().getNextId(); i++) {
    ConsensusInstance ci=storage.getLog().getInstance(i);
    if (ci.getValue() != null) {
      Deque<ClientBatch> reqs=batcher.unpack(ci.getValue());
switch (ci.getState()) {
case DECIDED:
        for (        ClientBatch replicaRequest : reqs) {
          decided.add(replicaRequest.getRequestId());
        }
      break;
case KNOWN:
    for (    ClientBatch replicaRequest : reqs) {
      known.add(replicaRequest.getRequestId());
    }
  break;
case UNKNOWN:
default :
break;
}
}
}
cliBManagerDispatcher.submit(new Runnable(){
@Override public void run(){
batchStore.onViewChange(known,decided);
batchStore.setProposerActive(true);
}
}
);
}

Fixed version (ground truth):
public void startProposing(final int view){
  final Set<ClientBatchID> decided=new HashSet<ClientBatchID>();
  final Set<ClientBatchID> known=new HashSet<ClientBatchID>();
  Storage storage=paxos.getStorage();
  if (logger.isLoggable(Level.FINE)) {
    logger.fine("String_Node_Str" + storage.getFirstUncommitted() + "String_Node_Str"+ storage.getLog().getNextId());
  }
  for (int i=storage.getFirstUncommitted(); i < storage.getLog().getNextId(); i++) {
    ConsensusInstance ci=storage.getLog().getInstance(i);
    if (ci.getValue() != null) {
      Deque<ClientBatch> reqs=batcher.unpack(ci.getValue());
switch (ci.getState()) {
case DECIDED:
        for (        ClientBatch replicaRequest : reqs) {
          decided.add(replicaRequest.getBatchId());
        }
      break;
case KNOWN:
    for (    ClientBatch replicaRequest : reqs) {
      known.add(replicaRequest.getBatchId());
    }
  break;
case UNKNOWN:
default :
break;
}
}
}
cliBManagerDispatcher.submit(new Runnable(){
@Override public void run(){
batchStore.onViewChange(view,known,decided);
}
}
);
}
Program: 18085
Project: 18085
Buggy source:
public void onBatchDecided(final int instance,final Deque<ClientBatch> batch){
  cliBManagerDispatcher.execute(new Runnable(){
    @Override public void run(){
      innerOnBatchDecided(instance,batch);
    }
  }
);
}

Fixed version (ground truth):
public void onBatchDecided(final int instance,final Deque<ClientBatch> batch){
  cliBManagerDispatcher.submit(new Runnable(){
    @Override public void run(){
      innerOnBatchDecided(instance,batch);
    }
  }
);
}
Program: 18086
Project: 18086
Buggy source:
public void stopProposing(){
  batchStore.setProposerActive(false);
}

Fixed version (ground truth):
public void stopProposing(){
  cliBManagerDispatcher.submit(new Runnable(){
    @Override public void run(){
      batchStore.stopProposing();
    }
  }
);
}
Program: 18087
Project: 18087
Buggy source:
void innerOnBatchDecided(int instance,Deque<ClientBatch> batch){
  if (logger.isLoggable(Level.INFO)) {
    logger.info("String_Node_Str" + instance + "String_Node_Str"+ batch.toString());
  }
  for (  ClientBatch req : batch) {
    ClientBatchID rid=req.getRequestId();
    ClientBatchInfo rInfo=batchStore.getRequestInfo(rid);
    if (rInfo == null) {
      rInfo=batchStore.newRequestInfo(req.getRequestId());
      batchStore.setRequestInfo(rid,rInfo);
    }
    rInfo.state=State.Decided;
    if (logger.isLoggable(Level.FINE)) {
      logger.fine(rInfo.toString());
    }
    if (logger.isLoggable(Level.INFO)) {
      if (rid.replicaID == localId) {
        logger.info("String_Node_Str" + rid + "String_Node_Str"+ (System.currentTimeMillis() - rInfo.timeStamp));
      }
    }
    executionQueue.add(rInfo);
  }
  executionQueue.add(instance);
  executeRequests();
  batchStore.pruneLogs();
}

Fixed version (ground truth):
void innerOnBatchDecided(int instance,Deque<ClientBatch> batch){
  if (logger.isLoggable(Level.INFO)) {
    logger.info("String_Node_Str" + instance + "String_Node_Str"+ batch.toString());
  }
  for (  ClientBatch req : batch) {
    ClientBatchID rid=req.getBatchId();
    if (rid.sn < batchStore.getLowerBound(rid.replicaID)) {
      logger.warning("String_Node_Str" + rid);
      continue;
    }
    ClientBatchInfo rInfo=batchStore.getRequestInfo(rid);
    if (rInfo == null) {
      rInfo=batchStore.newRequestInfo(req.getBatchId());
      batchStore.setRequestInfo(rid,rInfo);
    }
 else     if (rInfo.state == BatchState.Decided || rInfo.state == BatchState.Executed) {
      logger.warning("String_Node_Str" + rInfo);
      continue;
    }
    rInfo.state=BatchState.Decided;
    if (logger.isLoggable(Level.FINE)) {
      logger.fine(rInfo.toString());
    }
    if (logger.isLoggable(Level.INFO)) {
      if (rid.replicaID == localId) {
        logger.info("String_Node_Str" + rid + "String_Node_Str"+ (System.currentTimeMillis() - rInfo.timeStamp));
      }
    }
    executionQueue.add(rInfo);
  }
  executionQueue.add(instance);
  executeRequests();
  batchStore.pruneLogs();
}
Program: 18088
Project: 18088
Buggy source:
@Override public void onMessageReceived(final Message msg,final int sender){
  cliBManagerDispatcher.execute(new Runnable(){
    @Override public void run(){
      try {
        if (msg instanceof ForwardClientBatch) {
          onForwardClientBatch((ForwardClientBatch)msg,sender);
        }
 else         if (msg instanceof AckForwardClientBatch) {
          onAckForwardClientBatch((AckForwardClientBatch)msg,sender);
        }
 else {
          throw new AssertionError("String_Node_Str" + msg);
        }
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
  }
);
}

Fixed version (ground truth):
@Override public void onMessageReceived(final Message msg,final int sender){
  cliBManagerDispatcher.submit(new Runnable(){
    @Override public void run(){
      try {
        if (msg instanceof ForwardClientBatch) {
          onForwardClientBatch((ForwardClientBatch)msg,sender);
        }
 else         if (msg instanceof AckForwardClientBatch) {
          onAckForwardClientBatch((AckForwardClientBatch)msg,sender);
        }
 else {
          throw new AssertionError("String_Node_Str" + msg);
        }
      }
 catch (      InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }
  }
);
}
Program: 18089
Project: 18089
Buggy source:
/** 
 * Creates a <code>Message</code> from serialized byte array.
 * @param message - serialized byte array with message content
 * @return deserialized message
 */
public static Message readByteArray(byte[] message){
  DataInputStream input=new DataInputStream(new ByteArrayInputStream(message));
  return create(input);
}

Fixed version (ground truth):
/** 
 * Creates a <code>Message</code> from serialized byte array.
 * @param message - serialized byte array with message content
 * @return deserialized message
 * @throws ClassNotFoundException 
 * @throws IOException 
 */
public static Message readByteArray(byte[] message) throws IOException, ClassNotFoundException {
  DataInputStream input=new DataInputStream(new ByteArrayInputStream(message));
  return create(input);
}
Program: 18090
Project: 18090
Buggy source:
/** 
 * Reads byte array and creates message from it. Byte array must have been written by Message::toByteArray().
 * @param input - the input stream with serialized message inside
 * @return correct object from one of message subclasses
 * @throws IllegalArgumentException if a correct message could not be readfrom input
 */
private static Message createMine(DataInputStream input){
  MessageType type;
  Message message;
  try {
    type=MessageType.values()[input.readUnsignedByte()];
    message=createMessage(type,input);
  }
 catch (  EOFException e) {
    throw new IllegalArgumentException(e);
  }
catch (  Exception e) {
    throw new IllegalArgumentException("String_Node_Str",e);
  }
  return message;
}

Fixed version (ground truth):
/** 
 * Reads byte array and creates message from it. Byte array must have been written by Message::toByteArray().
 * @param input - the input stream with serialized message inside
 * @return correct object from one of message subclasses
 * @throws IOException 
 * @throws IllegalArgumentException if a correct message could not be readfrom input
 */
private static Message createMine(DataInputStream input) throws IOException {
  MessageType type=MessageType.values()[input.readUnsignedByte()];
  Message message=createMessage(type,input);
  return message;
}
Program: 18091
Project: 18091
Buggy source:
/** 
 * Creates a <code>Message</code> from input stream.
 * @param input - the input stream with serialized message
 * @return deserialized message
 */
public static Message create(DataInputStream input){
  if (Config.JAVA_SERIALIZATION) {
    try {
      return (Message)(new ObjectInputStream(input).readObject());
    }
 catch (    IOException e) {
      throw new IllegalArgumentException("String_Node_Str",e);
    }
catch (    ClassNotFoundException e) {
      throw new IllegalArgumentException("String_Node_Str",e);
    }
  }
  return createMine(input);
}

Fixed version (ground truth):
/** 
 * Creates a <code>Message</code> from input stream.
 * @param input - the input stream with serialized message
 * @return deserialized message
 */
public static Message create(DataInputStream input) throws IOException, ClassNotFoundException {
  if (Config.JAVA_SERIALIZATION) {
    return (Message)(new ObjectInputStream(input).readObject());
  }
  return createMine(input);
}
Program: 18092
Project: 18092
Buggy source:
public void run(){
  while (true) {
    logger.info("String_Node_Str" + replica.getId());
    try {
      connect();
    }
 catch (    InterruptedException e) {
      logger.severe("String_Node_Str");
      break;
    }
    logger.info("String_Node_Str" + replica.getId());
    while (true) {
      if (Thread.interrupted()) {
        logger.severe("String_Node_Str");
        close();
        return;
      }
      Message message;
      try {
        message=MessageFactory.create(input);
      }
 catch (      IllegalArgumentException e) {
        logger.log(Level.SEVERE,"String_Node_Str",e);
        close();
        break;
      }
      if (logger.isLoggable(Level.FINE)) {
        logger.fine("String_Node_Str" + replica.getId() + "String_Node_Str"+ message+ "String_Node_Str"+ message.byteSize());
      }
      network.fireReceiveMessage(message,replica.getId());
    }
  }
}

Fixed version (ground truth):
public void run(){
  while (true) {
    logger.info("String_Node_Str" + replica.getId());
    try {
      connect();
    }
 catch (    InterruptedException e) {
      logger.severe("String_Node_Str");
      break;
    }
    logger.info("String_Node_Str" + replica.getId());
    while (true) {
      if (Thread.interrupted()) {
        logger.severe("String_Node_Str");
        close();
        return;
      }
      Message message;
      try {
        message=MessageFactory.create(input);
      }
 catch (      Exception e) {
        logger.log(Level.SEVERE,"String_Node_Str",e);
        close();
        break;
      }
      if (logger.isLoggable(Level.FINE)) {
        logger.fine("String_Node_Str" + replica.getId() + "String_Node_Str"+ message+ "String_Node_Str"+ message.byteSize());
      }
      network.fireReceiveMessage(message,replica.getId());
    }
  }
}
Program: 18094
Project: 18094
Buggy source:
public void run(){
  logger.info(Thread.currentThread().getName() + "String_Node_Str");
  try {
    while (true) {
      byte[] buffer=new byte[p.maxUdpPacketSize + 4];
      DatagramPacket dp=new DatagramPacket(buffer,buffer.length);
      datagramSocket.receive(dp);
      ByteArrayInputStream bais=new ByteArrayInputStream(dp.getData(),dp.getOffset(),dp.getLength());
      DataInputStream dis=new DataInputStream(bais);
      int sender=dis.readInt();
      byte[] data=new byte[dp.getLength() - 4];
      dis.read(data);
      Message message=MessageFactory.readByteArray(data);
      if (logger.isLoggable(Level.FINE)) {
        logger.fine("String_Node_Str" + sender + "String_Node_Str"+ message);
      }
      fireReceiveMessage(message,sender);
    }
  }
 catch (  IOException e) {
    logger.log(Level.SEVERE,"String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void run(){
  logger.info(Thread.currentThread().getName() + "String_Node_Str");
  try {
    while (true) {
      byte[] buffer=new byte[p.maxUdpPacketSize + 4];
      DatagramPacket dp=new DatagramPacket(buffer,buffer.length);
      datagramSocket.receive(dp);
      ByteArrayInputStream bais=new ByteArrayInputStream(dp.getData(),dp.getOffset(),dp.getLength());
      DataInputStream dis=new DataInputStream(bais);
      int sender=dis.readInt();
      byte[] data=new byte[dp.getLength() - 4];
      dis.read(data);
      try {
        Message message=MessageFactory.readByteArray(data);
        if (logger.isLoggable(Level.FINE)) {
          logger.fine("String_Node_Str" + sender + "String_Node_Str"+ message);
        }
        fireReceiveMessage(message,sender);
      }
 catch (      ClassNotFoundException e) {
        logger.log(Level.WARNING,"String_Node_Str",e);
      }
    }
  }
 catch (  IOException e) {
    logger.log(Level.SEVERE,"String_Node_Str",e);
  }
}
Program: 18095
Project: 18095
Buggy source:
/** 
 * Starts the replica. <p> First the recovery phase is started and after that the replica joins the Paxos protocol and starts the client manager and the underlying service.
 * @throws IOException if some I/O error occurs
 */
public void start() throws IOException {
  logger.info("String_Node_Str");
  RecoveryAlgorithm recovery=createRecoveryAlgorithm(descriptor.crashModel);
  paxos=recovery.getPaxos();
  recovery.addRecoveryListener(new InnerRecoveryListener());
  recovery.start();
}

Fixed version (ground truth):
/** 
 * Starts the replica. <p> First the recovery phase is started and after that the replica joins the Paxos protocol and starts the client manager and the underlying service.
 * @throws IOException if some I/O error occurs
 */
public void start() throws IOException {
  logger.info("String_Node_Str");
  RecoveryAlgorithm recovery=createRecoveryAlgorithm(descriptor.crashModel);
  paxos=recovery.getPaxos();
  paxos.getDispatcher().start();
  paxos.getNetwork().start();
  paxos.getCatchup().start();
  recovery.addRecoveryListener(new InnerRecoveryListener());
  recovery.start();
}
Program: 18097
Project: 18097
Buggy source:
protected void ensureSnapshot(){
  if (snapshot == null) {
    snapshot=sha512.digest();
    snapshotSeqNo=lastExecuteSeqNo;
  }
}

Fixed version (ground truth):
protected void ensureSnapshot(){
  if (snapshot == null) {
    snapshot=previousDigest;
    snapshotSeqNo=lastExecuteSeqNo;
  }
}
Program: 18098
Project: 18098
Buggy source:
public synchronized byte[] execute(byte[] value,int executeSeqNo){
  lastExecuteSeqNo=executeSeqNo;
  byte[] digest=sha512.digest(value);
  StringBuffer sb=new StringBuffer();
  sb.append(executeSeqNo);
  sb.append(' ');
  sb.append(localId);
  sb.append(' ');
  sb.append(Arrays.toString(value).hashCode());
  sb.append(' ');
  sb.append(Arrays.toString(digest).hashCode());
  sb.append('\n');
  try {
    decisionsFile.writeBytes(sb.toString());
    decisionsFile.flush();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  if (random.nextInt(100) < 10) {
    snapshotSeqNo=executeSeqNo;
    snapshot=digest;
    if (random.nextInt(100) < 10) {
      fireSnapshotMade(snapshotSeqNo + 1,snapshot,digest);
    }
  }
  return digest;
}

Fixed version (ground truth):
public synchronized byte[] execute(byte[] value,int executeSeqNo){
  lastExecuteSeqNo=executeSeqNo;
  sha512.update(previousDigest);
  byte[] digest=sha512.digest(value);
  StringBuffer sb=new StringBuffer();
  sb.append(executeSeqNo);
  sb.append(' ');
  sb.append(localId);
  sb.append(' ');
  sb.append(Arrays.toString(value).hashCode());
  sb.append(' ');
  sb.append(Arrays.toString(digest).hashCode());
  sb.append('\n');
  try {
    decisionsFile.writeBytes(sb.toString());
    decisionsFile.flush();
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
  if (random.nextInt(100) < 10) {
    snapshotSeqNo=executeSeqNo;
    snapshot=digest;
    if (random.nextInt(100) < 10) {
      fireSnapshotMade(snapshotSeqNo + 1,snapshot,digest);
    }
  }
  previousDigest=digest;
  return digest;
}
Program: 18099
Project: 18099
Buggy source:
public void updateToSnapshot(int requestSeqNo,byte[] snapshot){
  sha512.reset();
  sha512.update(snapshot);
}

Fixed version (ground truth):
public void updateToSnapshot(int nextRequestSeqNo,byte[] snapshot){
  previousDigest=snapshot;
  this.snapshot=snapshot;
  snapshotSeqNo=nextRequestSeqNo - 1;
}
Program: 18100
Project: 18100
Buggy source:
public byte[] execute(byte[] value,int seqNo){
  Logger.getLogger(this.getClass().getCanonicalName()).info("String_Node_Str" + seqNo);
  if (random.nextInt(10) == 0) {
    assert(last != null);
    fireSnapshotMade(seqNo,last,value);
    Logger.getLogger(this.getClass().getCanonicalName()).info("String_Node_Str");
  }
  last=value;
  return value;
}

Fixed version (ground truth):
public byte[] execute(byte[] value,int seqNo){
  Logger.getLogger(this.getClass().getCanonicalName()).info("String_Node_Str" + seqNo);
  if (random.nextInt(10) == 0) {
    assert(last != null);
    fireSnapshotMade(seqNo + 1,last,value);
    Logger.getLogger(this.getClass().getCanonicalName()).info("String_Node_Str");
  }
  last=value;
  return value;
}
Program: 18101
Project: 18101
Buggy source:
/** 
 * Restores the service state from snapshot
 * @param requestSeqNo (last executed request sequential number + 1) beforesnapshot was made (i.e. next request to be executed no)
 * @param snapshot the snapshot itself
 */
void updateToSnapshot(int requestSeqNo,byte[] snapshot);

Fixed version (ground truth):
/** 
 * Restores the service state from snapshot
 * @param requestSeqNo (last executed request sequential number + 1) beforesnapshot was made (i.e. next request to be executed no)
 * @param snapshot the snapshot itself
 */
void updateToSnapshot(int nextRequestSeqNo,byte[] snapshot);
Program: 18102
Project: 18102
Buggy source:
public void onSnapshotMade(final Snapshot snapshot){
  dispatcher.checkInDispatcher();
  if (snapshot.getValue() == null)   throw new RuntimeException("String_Node_Str");
  Map<Long,Reply> requestHistory=new HashMap<Long,Reply>(executedRequests);
  for (int i=executeUB - 1; i >= snapshot.getNextInstanceId(); i--) {
    List<Reply> ides=executedDifference.get(i);
    if (ides == null)     continue;
    for (    Reply reply : ides) {
      requestHistory.put(reply.getRequestId().getClientId(),reply);
    }
  }
  while (!executedDifference.isEmpty() && executedDifference.firstKey() < snapshot.getNextInstanceId()) {
    executedDifference.pollFirstEntry();
  }
  snapshot.setLastReplyForClient(requestHistory);
  paxos.onSnapshotMade(snapshot);
}

Fixed version (ground truth):
public void onSnapshotMade(final Snapshot snapshot){
  dispatcher.checkInDispatcher();
  if (snapshot.getValue() == null)   throw new RuntimeException("String_Node_Str");
  Map<Long,Reply> requestHistory=new HashMap<Long,Reply>(previousSnapshotExecutedRequests);
  int prevSnapshotNextInstId;
  Snapshot lastSnapshot=paxos.getStorage().getLastSnapshot();
  if (lastSnapshot != null)   prevSnapshotNextInstId=lastSnapshot.getNextInstanceId();
 else   prevSnapshotNextInstId=0;
  for (int i=prevSnapshotNextInstId; i < snapshot.getNextInstanceId(); ++i) {
    List<Reply> ides=executedDifference.remove(i);
    if (ides == null)     continue;
    for (    Reply reply : ides) {
      requestHistory.put(reply.getRequestId().getClientId(),reply);
    }
  }
  snapshot.setLastReplyForClient(requestHistory);
  previousSnapshotExecutedRequests.clear();
  previousSnapshotExecutedRequests.putAll(requestHistory);
  paxos.onSnapshotMade(snapshot);
}
Program: 18103
Project: 18103
Buggy source:
/** 
 * Notifies this service proxy that all request from specified consensus instance has been executed.
 * @param instanceId - the id of executed consensus instance
 */
public void instanceExecuted(int instanceId){
  startingSeqNo.put(instanceId + 1,nextSeqNo);
}

Fixed version (ground truth):
/** 
 * Notifies this service proxy that all request from specified consensus instance has been executed.
 * @param instanceId - the id of executed consensus instance
 */
public void instanceExecuted(int instanceId){
  startingSeqNo.add(new Pair<Integer,Integer>(instanceId + 1,nextSeqNo));
}
Program: 18104
Project: 18104
Buggy source:
/** 
 * Creates new <code>ServiceProxy</code> instance.
 * @param service - the service wrapped by this proxy
 * @param responsesCache - the cache of responses from service
 * @param replicaDispatcher - the dispatcher used in replica
 */
public ServiceProxy(Service service,Map<Integer,List<Reply>> responsesCache,SingleThreadDispatcher replicaDispatcher){
  this.service=service;
  this.replicaDispatcher=replicaDispatcher;
  service.addSnapshotListener(this);
  this.responsesCache=responsesCache;
}

Fixed version (ground truth):
/** 
 * Creates new <code>ServiceProxy</code> instance.
 * @param service - the service wrapped by this proxy
 * @param responsesCache - the cache of responses from service
 * @param replicaDispatcher - the dispatcher used in replica
 */
public ServiceProxy(Service service,Map<Integer,List<Reply>> responsesCache,SingleThreadDispatcher replicaDispatcher){
  this.service=service;
  this.replicaDispatcher=replicaDispatcher;
  service.addSnapshotListener(this);
  this.responsesCache=responsesCache;
  startingSeqNo.add(new Pair<Integer,Integer>(0,0));
}
Program: 18105
Project: 18105
Buggy source:
/** 
 * Updates states of underlying service to specified snapshot.
 * @param snapshot - the snapshot with newer service state
 */
public void updateToSnapshot(Snapshot snapshot){
  lastSnapshotNextSeqNo=snapshot.getNextRequestSeqNo();
  nextSeqNo=snapshot.getStartingRequestSeqNo();
  skip=snapshot.getNextRequestSeqNo() - nextSeqNo;
  skippedCache=new LinkedList<Reply>(snapshot.getPartialResponseCache());
  startingSeqNo.put(snapshot.getNextInstanceId(),snapshot.getStartingRequestSeqNo());
  service.updateToSnapshot(lastSnapshotNextSeqNo,snapshot.getValue());
}

Fixed version (ground truth):
/** 
 * Updates states of underlying service to specified snapshot.
 * @param snapshot - the snapshot with newer service state
 */
public void updateToSnapshot(Snapshot snapshot){
  lastSnapshotNextSeqNo=snapshot.getNextRequestSeqNo();
  nextSeqNo=snapshot.getStartingRequestSeqNo();
  skip=snapshot.getNextRequestSeqNo() - nextSeqNo;
  skippedCache=new LinkedList<Reply>(snapshot.getPartialResponseCache());
  if (!startingSeqNo.isEmpty() && startingSeqNo.getLast().getValue() > nextSeqNo) {
    truncateStartingSeqNo(nextSeqNo);
  }
 else {
    startingSeqNo.clear();
    startingSeqNo.add(new Pair<Integer,Integer>(snapshot.getNextInstanceId(),snapshot.getStartingRequestSeqNo()));
  }
  service.updateToSnapshot(lastSnapshotNextSeqNo,snapshot.getValue());
}