Program: 113621
Project: 113621
Buggy source:
/** 
 * @param objectNo - relative object number.
 * @param firstByteInObject - the first byte to be read.
 * @param bytesInObject - the maximal number of bytes to be read.
 * @return a ReusableBuffer containing the data which was read.
 */
@Override public ReusableBuffer readObject(long objectNo,int offset,int length) throws IOException {
  RPCResponse<ObjectData> response=null;
  Logging.logMessage(Logging.LEVEL_DEBUG,Category.tool,this,"String_Node_Str",objectNo,fileId,xLoc.getOSDsForObject(objectNo).toString());
  List<ServiceUUID> osds=osdSelectionPolicy.getOSDorder(xLoc.getOSDsForObject(objectNo));
  int size=0;
  ObjectData data=null;
  ReusableBuffer buffer=null;
  for (  ServiceUUID osd : osds) {
    checkCap();
    try {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.tool,this,"String_Node_Str",objectNo,fileId,osd);
      response=osdClient.read(osd.getAddress(),fileId,fileCredentials,objectNo,0,offset,length);
      data=response.get();
      if (data.getInvalid_checksum_on_osd()) {
        throw new IOException("String_Node_Str" + objectNo + "String_Node_Str");
      }
      if (data.getZero_padding() == 0) {
        buffer=data.getData();
      }
 else {
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.tool,this,"String_Node_Str",objectNo,fileId);
        final int dataSize=data.getData().capacity();
        if (data.getData().enlarge(dataSize + data.getZero_padding())) {
          data.getData().position(dataSize);
          while (data.getData().hasRemaining())           data.getData().put((byte)0);
          buffer=data.getData();
          buffer.position(0);
        }
 else {
          buffer=BufferPool.allocate(dataSize + data.getZero_padding());
          buffer.put(data.getData());
          while (buffer.hasRemaining())           buffer.put((byte)0);
          buffer.position(0);
          BufferPool.free(data.getData());
        }
      }
      break;
    }
 catch (    ONCRPCException ex) {
      System.out.println(ex.toString());
      if (buffer != null)       BufferPool.free(buffer);
      if (((OSDException)ex).getError_code() == ErrorCodes.IO_ERROR || osds.lastIndexOf(osd) == osds.size() - 1) {
        throw new IOException("String_Node_Str",ex);
      }
 else       continue;
    }
catch (    IOException ex) {
      System.out.println(ex.toString());
      if (buffer != null)       BufferPool.free(buffer);
      if (osds.lastIndexOf(osd) == osds.size() - 1) {
        throw new IOException("String_Node_Str",ex);
      }
 else       continue;
    }
catch (    InterruptedException ex) {
    }
 finally {
      if (response != null) {
        response.freeBuffers();
      }
    }
  }
  return buffer;
}

Fixed version (ground truth):
/** 
 * @param objectNo - relative object number.
 * @param firstByteInObject - the first byte to be read.
 * @param bytesInObject - the maximal number of bytes to be read.
 * @return a ReusableBuffer containing the data which was read.
 */
@Override public ReusableBuffer readObject(long objectNo,int offset,int length) throws IOException {
  RPCResponse<ObjectData> response=null;
  Logging.logMessage(Logging.LEVEL_DEBUG,Category.tool,this,"String_Node_Str",objectNo,fileId,xLoc.getOSDsForObject(objectNo).toString());
  List<ServiceUUID> osds=osdSelectionPolicy.getOSDorder(xLoc.getOSDsForObject(objectNo));
  int size=0;
  ObjectData data=null;
  ReusableBuffer buffer=null;
  for (  ServiceUUID osd : osds) {
    checkCap();
    try {
      Logging.logMessage(Logging.LEVEL_DEBUG,Category.tool,this,"String_Node_Str",objectNo,fileId,osd);
      response=osdClient.read(osd.getAddress(),fileId,fileCredentials,objectNo,0,offset,length);
      data=response.get();
      if (data.getInvalid_checksum_on_osd()) {
        throw new IOException("String_Node_Str" + objectNo + "String_Node_Str");
      }
      if (data.getZero_padding() == 0) {
        buffer=data.getData();
      }
 else {
        Logging.logMessage(Logging.LEVEL_DEBUG,Category.tool,this,"String_Node_Str",objectNo,fileId);
        final int dataSize=data.getData().capacity();
        if (data.getData().enlarge(dataSize + data.getZero_padding())) {
          data.getData().position(dataSize);
          while (data.getData().hasRemaining())           data.getData().put((byte)0);
          buffer=data.getData();
          buffer.position(0);
        }
 else {
          buffer=BufferPool.allocate(dataSize + data.getZero_padding());
          buffer.put(data.getData());
          while (buffer.hasRemaining())           buffer.put((byte)0);
          buffer.position(0);
          BufferPool.free(data.getData());
        }
      }
      break;
    }
 catch (    ONCRPCException ex) {
      if (buffer != null)       BufferPool.free(buffer);
      if (osds.lastIndexOf(osd) == osds.size() - 1 || ((OSDException)ex).getError_code() == ErrorCodes.IO_ERROR) {
        throw new IOException("String_Node_Str",ex);
      }
 else       continue;
    }
catch (    IOException ex) {
      if (buffer != null)       BufferPool.free(buffer);
      if (osds.lastIndexOf(osd) == osds.size() - 1) {
        throw new IOException("String_Node_Str",ex);
      }
 else       continue;
    }
catch (    InterruptedException ex) {
    }
 finally {
      if (response != null) {
        response.freeBuffers();
      }
    }
  }
  return buffer;
}