Program: 52662
Project: 52662
Buggy source:
/** 
 * Put a single block.
 * @param in
 * @param blockIndex
 * @param blockSize
 * @param chunkSize
 * @param retries If fails, how many times should it retry to upload?
 * @param progress
 * @param notifier
 */
public ResumablePutRet resumablePutBlock(RandomAccessFile file,int blockIndex,long blockSize,long chunkSize,int retryTimes,BlockProgress progress,BlockProgressNotifier notifier){
  ResumablePutRet ret=null;
  if (progress.context == null || progress.context.isEmpty()) {
    int bodyLength=(int)((blockSize > chunkSize) ? chunkSize : blockSize);
    byte[] body=new byte[bodyLength];
    try {
      file.seek(Config.BLOCK_SIZE * blockIndex);
      int readBytes=file.read(body,0,bodyLength);
      if (readBytes != bodyLength) {
        return new ResumablePutRet(new CallRet(400,"String_Node_Str"));
      }
      ret=makeBlock((int)blockSize,body,bodyLength);
      if (!ret.ok()) {
        return ret;
      }
      CRC32 crc32=new CRC32();
      crc32.update(body,0,bodyLength);
      if (ret.getCrc32() != crc32.getValue()) {
        ret.statusCode=400;
        return ret;
      }
      progress.context=ret.getCtx();
      progress.offset=bodyLength;
      progress.restSize=blockSize - bodyLength;
      notifier.notify(blockIndex,progress);
    }
 catch (    IOException e) {
      e.printStackTrace();
      return new ResumablePutRet(new CallRet(400,e));
    }
  }
 else   if (progress.offset + progress.restSize != blockSize) {
    return new ResumablePutRet(new CallRet(400,"String_Node_Str"));
  }
  while (progress.restSize > 0) {
    int bodyLength=(int)((chunkSize < progress.restSize) ? chunkSize : progress.restSize);
    byte[] body=new byte[bodyLength];
    for (int retries=retryTimes; retries > 0; --retries) {
      try {
        file.seek(blockIndex * Config.BLOCK_SIZE + progress.offset);
        int readBytes=file.read(body,0,bodyLength);
        if (readBytes != bodyLength) {
          return new ResumablePutRet(new CallRet(400,"String_Node_Str"));
        }
        ret=putBlock(blockSize,progress.context,progress.offset,body,bodyLength);
        if (ret.ok()) {
          CRC32 crc32=new CRC32();
          crc32.update(body,0,bodyLength);
          if (ret.getCrc32() == crc32.getValue()) {
            progress.context=ret.getCtx();
            progress.offset+=bodyLength;
            progress.restSize-=bodyLength;
            notifier.notify(blockIndex,progress);
            break;
          }
        }
 else         if (ret.getStatusCode() == INVALID_CTX) {
          progress.context="String_Node_Str";
          notifier.notify(blockIndex,progress);
          return ret;
        }
      }
 catch (      IOException e) {
        e.printStackTrace();
        return new ResumablePutRet(new CallRet(400,e));
      }
    }
  }
  if (ret == null) {
    ret=new ResumablePutRet(new CallRet(400,(String)null));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * Put a single block.
 * @param in
 * @param blockIndex
 * @param blockSize
 * @param chunkSize
 * @param retries If fails, how many times should it retry to upload?
 * @param progress
 * @param notifier
 */
public ResumablePutRet resumablePutBlock(String upHost,RandomAccessFile file,int blockIndex,long blockSize,long chunkSize,int retryTimes,BlockProgress progress,BlockProgressNotifier notifier){
  ResumablePutRet ret=null;
  if (progress.context == null || progress.context.isEmpty()) {
    int bodyLength=(int)((blockSize > chunkSize) ? chunkSize : blockSize);
    byte[] body=new byte[bodyLength];
    try {
      file.seek(Config.BLOCK_SIZE * blockIndex);
      int readBytes=file.read(body,0,bodyLength);
      if (readBytes != bodyLength) {
        return new ResumablePutRet(new CallRet(400,"String_Node_Str"));
      }
      ret=makeBlock(upHost,(int)blockSize,body,bodyLength);
      upHost=ret.getHost();
      if (!ret.ok()) {
        return ret;
      }
      CRC32 crc32=new CRC32();
      crc32.update(body,0,bodyLength);
      if (ret.getCrc32() != crc32.getValue()) {
        ret.statusCode=400;
        return ret;
      }
      progress.context=ret.getCtx();
      progress.offset=bodyLength;
      progress.restSize=blockSize - bodyLength;
      notifier.notify(blockIndex,progress);
    }
 catch (    IOException e) {
      e.printStackTrace();
      return new ResumablePutRet(new CallRet(400,e));
    }
  }
 else   if (progress.offset + progress.restSize != blockSize) {
    return new ResumablePutRet(new CallRet(400,"String_Node_Str"));
  }
  while (progress.restSize > 0) {
    int bodyLength=(int)((chunkSize < progress.restSize) ? chunkSize : progress.restSize);
    byte[] body=new byte[bodyLength];
    for (int retries=retryTimes; retries > 0; --retries) {
      try {
        file.seek(blockIndex * Config.BLOCK_SIZE + progress.offset);
        int readBytes=file.read(body,0,bodyLength);
        if (readBytes != bodyLength) {
          return new ResumablePutRet(new CallRet(400,"String_Node_Str"));
        }
        ret=putBlock(upHost,blockSize,progress.context,progress.offset,body,bodyLength);
        if (ret.ok()) {
          CRC32 crc32=new CRC32();
          crc32.update(body,0,bodyLength);
          if (ret.getCrc32() == crc32.getValue()) {
            progress.context=ret.getCtx();
            progress.offset+=bodyLength;
            progress.restSize-=bodyLength;
            notifier.notify(blockIndex,progress);
            break;
          }
        }
 else         if (ret.getStatusCode() == INVALID_CTX) {
          progress.context="String_Node_Str";
          notifier.notify(blockIndex,progress);
          return ret;
        }
      }
 catch (      IOException e) {
        e.printStackTrace();
        return new ResumablePutRet(new CallRet(400,e));
      }
    }
  }
  if (ret == null) {
    ret=new ResumablePutRet(new CallRet(400,(String)null));
  }
  return ret;
}