Program: 113518
Project: 113518
Buggy source:
public int write(ReusableBuffer data) throws IOException {
  if (readOnly) {
    throw new IOException("String_Node_Str");
  }
  if (closed) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (data.remaining() == 0) {
    return 0;
  }
  List<ObjectRequest> ors=oMapper.writeRequest(data,position,currentReplica);
  if (ors.size() == 0) {
    return 0;
  }
  int numTries=0;
  IOException cause=null;
  do {
    final AtomicInteger responseCnt=new AtomicInteger(ors.size());
    RPCResponse[] resps=new RPCResponse[ors.size()];
    try {
      final RPCResponseAvailableListener rl=new RPCResponseAvailableListener<OSDWriteResponse>(){
        @Override public void responseAvailable(        RPCResponse<OSDWriteResponse> r){
          if (responseCnt.decrementAndGet() == 0) {
synchronized (responseCnt) {
              responseCnt.notify();
            }
          }
        }
      }
;
      int bytesWritten=0;
      setXCap();
      for (int i=0; i < ors.size(); i++) {
        ObjectRequest or=ors.get(i);
        or.getData().position(0);
        bytesWritten+=or.getData().capacity();
        ServiceUUID osd=new ServiceUUID(or.getOsdUUID(),parentVolume.uuidResolver);
        RPCResponse<OSDWriteResponse> r=osdClient.write(osd.getAddress(),fileId,credentials,or.getObjNo(),-1,or.getOffset(),0l,new ObjectData(0,false,0,or.getData()));
        resps[i]=r;
        r.registerListener(rl);
      }
synchronized (responseCnt) {
        if (responseCnt.get() > 0) {
          responseCnt.wait();
        }
      }
      OSDWriteResponse owr=null;
      for (int i=0; i < ors.size(); i++) {
        owr=(OSDWriteResponse)resps[i].get();
      }
      setXCap();
      parentVolume.storeFileSizeUpdate(fileId,owr);
      if (syncMetadata) {
        parentVolume.pushFileSizeUpdate(fileId);
      }
      data.flip();
      position+=bytesWritten;
      return bytesWritten;
    }
 catch (    InterruptedException ex) {
      cause=new IOException("String_Node_Str",ex);
    }
catch (    RedirectException ex) {
      if (Logging.isDebug())       Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",ex.getTo_uuid());
      forceReplica(ex.getTo_uuid());
      continue;
    }
catch (    ONCRPCException ex) {
      cause=new IOException("String_Node_Str" + ex,ex);
    }
 finally {
      for (      RPCResponse r : resps) {
        if (r != null)         r.freeBuffers();
      }
    }
    numTries++;
    switchToNextReplica();
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",cause,currentReplica);
  }
 while (numTries < numReplicas);
  throw cause;
}

Fixed version (ground truth):
public int write(ReusableBuffer data) throws IOException {
  if (readOnly) {
    throw new IOException("String_Node_Str");
  }
  if (closed) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (data.remaining() == 0) {
    return 0;
  }
  List<ObjectRequest> ors=oMapper.writeRequest(data,position,currentReplica);
  if (ors.size() == 0) {
    return 0;
  }
  int numTries=0;
  IOException cause=null;
  do {
    final AtomicInteger responseCnt=new AtomicInteger(ors.size());
    RPCResponse[] resps=new RPCResponse[ors.size()];
    try {
      final RPCResponseAvailableListener rl=new RPCResponseAvailableListener<OSDWriteResponse>(){
        @Override public void responseAvailable(        RPCResponse<OSDWriteResponse> r){
          if (responseCnt.decrementAndGet() == 0) {
synchronized (responseCnt) {
              responseCnt.notify();
            }
          }
        }
      }
;
      int bytesWritten=0;
      setXCap();
      for (int i=0; i < ors.size(); i++) {
        ObjectRequest or=ors.get(i);
        or.getData().position(0);
        bytesWritten+=or.getData().capacity();
        ServiceUUID osd=new ServiceUUID(or.getOsdUUID(),parentVolume.uuidResolver);
        RPCResponse<OSDWriteResponse> r=osdClient.write(osd.getAddress(),fileId,credentials,or.getObjNo(),-1,or.getOffset(),0l,new ObjectData(0,false,0,or.getData()));
        resps[i]=r;
        r.registerListener(rl);
      }
synchronized (responseCnt) {
        if (responseCnt.get() > 0) {
          responseCnt.wait();
        }
      }
      OSDWriteResponse owr=null;
      for (int i=0; i < ors.size(); i++) {
        owr=(OSDWriteResponse)resps[i].get();
      }
      setXCap();
      parentVolume.storeFileSizeUpdate(fileId,owr);
      if (syncMetadata) {
        parentVolume.pushFileSizeUpdate(fileId);
      }
      data.flip();
      position+=bytesWritten;
      return bytesWritten;
    }
 catch (    InterruptedException ex) {
      cause=new IOException("String_Node_Str",ex);
    }
catch (    RedirectException ex) {
      if (Logging.isDebug())       Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",ex.getTo_uuid());
      forceReplica(ex.getTo_uuid());
      continue;
    }
catch (    ONCRPCException ex) {
      cause=new IOException("String_Node_Str" + ex,ex);
    }
 finally {
      for (      RPCResponse r : resps) {
        if (r != null)         r.freeBuffers();
      }
    }
    numTries++;
    switchToNextReplica();
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",cause,currentReplica);
    try {
      Thread.sleep(WAIT_MS_BETWEEN_WRITE_SWITCHOVER);
    }
 catch (    InterruptedException ex) {
      if (Logging.isDebug())       Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str",ex.toString());
      throw new IOException("String_Node_Str",ex);
    }
  }
 while (numTries < numReplicas);
  throw cause;
}