Program: 113376
Project: 113376
Buggy source:
/** 
 * Send update requests to every replica in the xLocSet that is not already up to date.
 * @param fileId
 * @param cap
 * @param xLocSet
 * @param authState
 * @param numAcksRequired
 * @param replicasUpToDate
 * @throws InterruptedException
 * @throws MRCException
 */
private void updateReplicas(String fileId,Capability cap,XLocSet xLocSet,AuthoritativeReplicaState authState,int numAcksRequired,Set<String> replicasUpToDate) throws InterruptedException, MRCException {
  final OSDServiceClient client=master.getOSDClient();
  ArrayList<ServiceUUID> OSDServiceUUIDs=new ArrayList<ServiceUUID>();
  for (int i=0; i < xLocSet.getReplicasCount(); i++) {
    String OSDUUID=Helper.getOSDUUIDFromXlocSet(xLocSet,i,0);
    if (!replicasUpToDate.contains(OSDUUID.toString())) {
      OSDServiceUUIDs.add(new ServiceUUID(OSDUUID));
    }
  }
  FileCredentials fileCredentials=FileCredentials.newBuilder().setXlocs(xLocSet).setXcap(cap.getXCap()).build();
  xtreemfs_rwr_auth_stateRequest authStateRequest=xtreemfs_rwr_auth_stateRequest.newBuilder().setFileId(fileId).setFileCredentials(fileCredentials).setState(authState).build();
  @SuppressWarnings("String_Node_Str") final RPCResponse<emptyResponse>[] responses=new RPCResponse[OSDServiceUUIDs.size()];
  for (int i=0; i < OSDServiceUUIDs.size(); i++) {
    try {
      final ServiceUUID OSDUUID=OSDServiceUUIDs.get(i);
      @SuppressWarnings("String_Node_Str") final RPCResponse<emptyResponse> rpcResponse=client.xtreemfs_rwr_auth_state_invalidated(OSDUUID.getAddress(),RPCAuthentication.authNone,RPCAuthentication.userService,authStateRequest);
      responses[i]=rpcResponse;
    }
 catch (    IOException ex) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_DEBUG,this,ex);
      }
    }
  }
  /** 
 * This local class is used to collect responses to the asynchronous update requests.<br> It counts the number of errors and successful requests.
 */
class FetchInvalidatedResponseListener implements RPCResponseAvailableListener<emptyResponse> {
    private int numResponses=0;
    private int numErrors=0;
    FetchInvalidatedResponseListener(    RPCResponse<emptyResponse>[] responses){
      for (int i=0; i < responses.length; i++) {
        responses[i].registerListener(this);
      }
    }
    @Override synchronized public void responseAvailable(    RPCResponse<emptyResponse> r){
      try {
        r.get();
        numResponses++;
      }
 catch (      Exception ex) {
        numErrors++;
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str",ex.toString());
      }
 finally {
        r.freeBuffers();
        this.notifyAll();
      }
    }
  }
  FetchInvalidatedResponseListener listener=new FetchInvalidatedResponseListener(responses);
  int numRequiredUpdates=numAcksRequired - replicasUpToDate.size();
  int numMaxErrors=OSDServiceUUIDs.size() - numRequiredUpdates;
synchronized (listener) {
    while (listener.numResponses < numRequiredUpdates) {
      listener.wait();
      if (listener.numErrors > numMaxErrors) {
        throw new MRCException("String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Send update requests to every replica in the xLocSet that is not already up to date.
 * @param fileId
 * @param cap
 * @param xLocSet
 * @param authState
 * @param numAcksRequired
 * @param replicasUpToDate
 * @throws InterruptedException
 * @throws MRCException
 */
private void updateReplicas(String fileId,Capability cap,XLocSet xLocSet,AuthoritativeReplicaState authState,int numAcksRequired,Set<String> replicasUpToDate) throws InterruptedException, MRCException {
  final OSDServiceClient client=master.getOSDClient();
  ArrayList<ServiceUUID> OSDServiceUUIDs=new ArrayList<ServiceUUID>();
  for (int i=0; i < xLocSet.getReplicasCount(); i++) {
    String OSDUUID=Helper.getOSDUUIDFromXlocSet(xLocSet,i,0);
    if (!replicasUpToDate.contains(OSDUUID.toString())) {
      OSDServiceUUIDs.add(new ServiceUUID(OSDUUID));
    }
  }
  FileCredentials fileCredentials=FileCredentials.newBuilder().setXlocs(xLocSet).setXcap(cap.getXCap()).build();
  xtreemfs_rwr_auth_stateRequest authStateRequest=xtreemfs_rwr_auth_stateRequest.newBuilder().setFileId(fileId).setFileCredentials(fileCredentials).setState(authState).build();
  @SuppressWarnings("String_Node_Str") final RPCResponse<emptyResponse>[] responses=new RPCResponse[OSDServiceUUIDs.size()];
  for (int i=0; i < OSDServiceUUIDs.size(); i++) {
    try {
      final ServiceUUID OSDUUID=OSDServiceUUIDs.get(i);
      @SuppressWarnings("String_Node_Str") final RPCResponse<emptyResponse> rpcResponse=client.xtreemfs_rwr_auth_state_invalidated(OSDUUID.getAddress(),RPCAuthentication.authNone,RPCAuthentication.userService,authStateRequest);
      responses[i]=rpcResponse;
    }
 catch (    IOException ex) {
      if (Logging.isDebug()) {
        Logging.logError(Logging.LEVEL_DEBUG,this,ex);
      }
      throw new MRCException(ex);
    }
  }
  /** 
 * This local class is used to collect responses to the asynchronous update requests.<br> It counts the number of errors and successful requests.
 */
class FetchInvalidatedResponseListener implements RPCResponseAvailableListener<emptyResponse> {
    private int numResponses=0;
    private int numErrors=0;
    FetchInvalidatedResponseListener(    RPCResponse<emptyResponse>[] responses){
      for (int i=0; i < responses.length; i++) {
        responses[i].registerListener(this);
      }
    }
    @Override synchronized public void responseAvailable(    RPCResponse<emptyResponse> r){
      try {
        r.get();
        numResponses++;
      }
 catch (      Exception ex) {
        numErrors++;
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.replication,this,"String_Node_Str",ex.toString());
      }
 finally {
        r.freeBuffers();
        this.notifyAll();
      }
    }
  }
  FetchInvalidatedResponseListener listener=new FetchInvalidatedResponseListener(responses);
  int numRequiredUpdates=numAcksRequired - replicasUpToDate.size();
  int numMaxErrors=OSDServiceUUIDs.size() - numRequiredUpdates;
synchronized (listener) {
    while (listener.numResponses < numRequiredUpdates) {
      listener.wait();
      if (listener.numErrors > numMaxErrors) {
        throw new MRCException("String_Node_Str");
      }
    }
  }
}