Program: 36877
Project: 36877
Buggy source:
/** 
 * begin the upload process via the following steps: 1. set the LinkedList of Chunk within the item we want to upload 2. create chunks for all units of the item we want to upload 3. send upload POST request for each chunk
 */
private void resumable(){
  logger.info("String_Node_Str");
  int numChunks=uploadItem.getChunkData().getNumberOfUnits();
  int unitSize=uploadItem.getChunkData().getUnitSize();
  long fileSize=uploadItem.getFileData().getFileSize();
  for (int chunkNumber=0; chunkNumber < numChunks; chunkNumber++) {
    logger.info("String_Node_Str");
    if (uploadItem.getBitmap().isUploaded(chunkNumber)) {
      logger.info("String_Node_Str" + chunkNumber + "String_Node_Str");
    }
 else {
      logger.info("String_Node_Str" + chunkNumber + "String_Node_Str");
      int chunkSize=getChunkSize(chunkNumber,numChunks,fileSize,unitSize);
      FileInputStream fis;
      BufferedInputStream bis;
      String chunkHash;
      String encodedShortFileName;
      byte[] chunkData;
      try {
        fis=new FileInputStream(uploadItem.getFileData().getFilePath());
        bis=new BufferedInputStream(fis);
        chunkData=createUploadChunk(chunkSize,bis);
        chunkHash=getSHA256(chunkData);
        encodedShortFileName=URLEncoder.encode(uploadItem.getFileName(),"String_Node_Str");
        fis.close();
        bis.close();
      }
 catch (      FileNotFoundException e) {
        this.exceptionHandler(e);
        return;
      }
catch (      NoSuchAlgorithmException e) {
        this.exceptionHandler(e);
        return;
      }
catch (      UnsupportedEncodingException e) {
        this.exceptionHandler(e);
        return;
      }
catch (      IOException e) {
        this.exceptionHandler(e);
        return;
      }
      HashMap<String,String> headers=generatePostHeaders(encodedShortFileName,fileSize,chunkNumber,chunkHash,chunkSize);
      HashMap<String,String> parameters=generateGetParameters();
      String jsonResponse;
      try {
        jsonResponse=sessionManager.getHttpInterface().sendPostRequest(sessionManager.getDomain(),UPLOAD_URI,parameters,headers,chunkData);
      }
 catch (      IOException e) {
        e.printStackTrace();
        notifyManagerException(e);
        return;
      }
      if (jsonResponse.isEmpty()) {
        notifyManagerLostConnection();
        return;
      }
      Gson gson=new Gson();
      ResumableResponse response=gson.fromJson(getResponseString(jsonResponse),ResumableResponse.class);
      if (shouldSetPollUploadKey(response)) {
        uploadItem.setPollUploadKey(response.getDoUpload().getKey());
      }
      if (response.hasError()) {
        notifyManagerCancelled(response);
        return;
      }
      if (response.getDoUpload().getResultCode() != ResumableResultCode.NO_ERROR) {
        if (response.getDoUpload().getResultCode() != ResumableResultCode.SUCCESS_FILE_MOVED_TO_ROOT) {
          notifyManagerCancelled(response);
          return;
        }
      }
    }
    notifyListenersProgressUpdate(chunkNumber,numChunks);
  }
  notifyManagerCompleted();
}

Fixed version (ground truth):
/** 
 * begin the upload process via the following steps: 1. set the LinkedList of Chunk within the item we want to upload 2. create chunks for all units of the item we want to upload 3. send upload POST request for each chunk
 */
private void resumable(){
  logger.info("String_Node_Str");
  int numChunks=uploadItem.getChunkData().getNumberOfUnits();
  int unitSize=uploadItem.getChunkData().getUnitSize();
  long fileSize=uploadItem.getFileData().getFileSize();
  logger.info("String_Node_Str" + numChunks);
  logger.info("String_Node_Str" + unitSize);
  logger.info("String_Node_Str" + fileSize);
  for (int chunkNumber=0; chunkNumber < numChunks; chunkNumber++) {
    logger.info("String_Node_Str");
    if (uploadItem.getBitmap().isUploaded(chunkNumber)) {
      logger.info("String_Node_Str" + chunkNumber + "String_Node_Str");
    }
 else {
      logger.info("String_Node_Str" + chunkNumber + "String_Node_Str");
      int chunkSize=getChunkSize(chunkNumber,numChunks,fileSize,unitSize);
      FileInputStream fis;
      BufferedInputStream bis;
      String chunkHash;
      String encodedShortFileName;
      byte[] chunkData;
      try {
        fis=new FileInputStream(uploadItem.getFileData().getFilePath());
        bis=new BufferedInputStream(fis);
        chunkData=createUploadChunk(unitSize,chunkNumber,bis);
        chunkHash=getSHA256(chunkData);
        encodedShortFileName=URLEncoder.encode(uploadItem.getFileName(),"String_Node_Str");
        logger.info("String_Node_Str" + chunkNumber + "String_Node_Str"+ chunkHash);
        logger.info("String_Node_Str" + chunkNumber + "String_Node_Str"+ chunkSize);
        logger.info("String_Node_Str" + chunkNumber + "String_Node_Str"+ encodedShortFileName);
        fis.close();
        bis.close();
      }
 catch (      FileNotFoundException e) {
        this.exceptionHandler(e);
        return;
      }
catch (      NoSuchAlgorithmException e) {
        this.exceptionHandler(e);
        return;
      }
catch (      UnsupportedEncodingException e) {
        this.exceptionHandler(e);
        return;
      }
catch (      IOException e) {
        this.exceptionHandler(e);
        return;
      }
      HashMap<String,String> headers=generatePostHeaders(encodedShortFileName,fileSize,chunkNumber,chunkHash,chunkSize);
      HashMap<String,String> parameters=generateGetParameters();
      String jsonResponse;
      try {
        jsonResponse=sessionManager.getHttpInterface().sendPostRequest(sessionManager.getDomain(),UPLOAD_URI,parameters,headers,chunkData);
      }
 catch (      IOException e) {
        e.printStackTrace();
        notifyManagerException(e);
        return;
      }
      if (jsonResponse.isEmpty()) {
        notifyManagerLostConnection();
        return;
      }
      Gson gson=new Gson();
      ResumableResponse response=gson.fromJson(getResponseString(jsonResponse),ResumableResponse.class);
      if (shouldSetPollUploadKey(response)) {
        logger.info("String_Node_Str" + response.getDoUpload().getPollUploadKey());
        uploadItem.setPollUploadKey(response.getDoUpload().getPollUploadKey());
      }
      if (response.hasError()) {
        logger.info("String_Node_Str" + response.getErrorNumber() + "String_Node_Str"+ response.getMessage());
        notifyManagerCancelled(response);
        return;
      }
      if (response.getDoUpload().getResultCode() != ResumableResultCode.NO_ERROR) {
        if (response.getDoUpload().getResultCode() != ResumableResultCode.SUCCESS_FILE_MOVED_TO_ROOT) {
          logger.info("String_Node_Str" + response.getDoUpload().getResultCode().toString());
          notifyManagerCancelled(response);
          return;
        }
      }
    }
    notifyListenersProgressUpdate(chunkNumber,numChunks);
  }
  notifyManagerCompleted();
}