Program: 52629
Project: 52629
Buggy source:
private Response upload0() throws QiniuException {
  if (host == null) {
    this.host=configuration.upHost(upToken);
  }
  long uploaded=0;
  int ret=0;
  boolean retry=false;
  int contextIndex=0;
  while (size == 0) {
    int bufferIndex=0;
    int blockSize=0;
    while (ret != -1 && bufferIndex != blockBuffer.length) {
      try {
        blockSize=blockBuffer.length - bufferIndex;
        ret=stream.read(blockBuffer,bufferIndex,blockSize);
      }
 catch (      IOException e) {
        close();
        throw new QiniuException(e);
      }
      if (ret != -1) {
        bufferIndex+=ret;
        if (ret == 0) {
          try {
            Thread.sleep(100);
          }
 catch (          InterruptedException e) {
            e.printStackTrace();
          }
        }
      }
 else {
        size=uploaded + bufferIndex;
      }
    }
    long crc=Crc32.bytes(blockBuffer,0,blockSize);
    Response response=null;
    QiniuException temp=null;
    try {
      response=makeBlock(blockBuffer,bufferIndex);
    }
 catch (    QiniuException e) {
      if (e.code() < 0) {
        host=configuration.upHostBackup(upToken);
      }
      if (e.response == null || e.response.needRetry()) {
        retry=true;
        temp=e;
      }
 else {
        close();
        throw e;
      }
    }
    if (!retry) {
      ResumeBlockInfo blockInfo0=response.jsonToObject(ResumeBlockInfo.class);
      if (blockInfo0.crc32 != crc) {
        retry=true;
        temp=new QiniuException(new Exception("String_Node_Str"));
      }
    }
    if (retry) {
      if (retryMax > 0) {
        retryMax--;
        try {
          response=makeBlock(blockBuffer,bufferIndex);
          retry=false;
        }
 catch (        QiniuException e) {
          close();
          throw e;
        }
      }
 else {
        throw temp;
      }
    }
    ResumeBlockInfo blockInfo=response.jsonToObject(ResumeBlockInfo.class);
    contexts.add(blockInfo.ctx);
    uploaded+=bufferIndex;
  }
  close();
  try {
    return makeFile();
  }
 catch (  QiniuException e) {
    try {
      return makeFile();
    }
 catch (    QiniuException e1) {
      throw e1;
    }
  }
}

Fixed version (ground truth):
private Response upload0() throws QiniuException {
  if (host == null) {
    this.host=configuration.upHost(upToken);
  }
  long uploaded=0;
  int ret=0;
  boolean retry=false;
  while (size == 0) {
    int bufferIndex=0;
    int blockSize=0;
    while (ret != -1 && bufferIndex != blockBuffer.length) {
      try {
        blockSize=blockBuffer.length - bufferIndex;
        ret=stream.read(blockBuffer,bufferIndex,blockSize);
      }
 catch (      IOException e) {
        close();
        throw new QiniuException(e);
      }
      if (ret != -1) {
        bufferIndex+=ret;
        if (ret == 0) {
          try {
            Thread.sleep(100);
          }
 catch (          InterruptedException e) {
            e.printStackTrace();
          }
        }
      }
 else {
        size=uploaded + bufferIndex;
      }
    }
    long crc=Crc32.bytes(blockBuffer,0,bufferIndex);
    Response response=null;
    QiniuException temp=null;
    try {
      response=makeBlock(blockBuffer,bufferIndex);
    }
 catch (    QiniuException e) {
      if (e.code() < 0) {
        host=configuration.upHostBackup(upToken);
      }
      if (e.response == null || e.response.needRetry()) {
        retry=true;
        temp=e;
      }
 else {
        close();
        throw e;
      }
    }
    if (!retry) {
      ResumeBlockInfo blockInfo0=response.jsonToObject(ResumeBlockInfo.class);
      if (blockInfo0.crc32 != crc) {
        retry=true;
        temp=new QiniuException(new Exception("String_Node_Str"));
      }
    }
    if (retry) {
      if (retryMax > 0) {
        retryMax--;
        try {
          response=makeBlock(blockBuffer,bufferIndex);
          retry=false;
        }
 catch (        QiniuException e) {
          close();
          throw e;
        }
      }
 else {
        throw temp;
      }
    }
    ResumeBlockInfo blockInfo=response.jsonToObject(ResumeBlockInfo.class);
    contexts.add(blockInfo.ctx);
    uploaded+=bufferIndex;
  }
  close();
  try {
    return makeFile();
  }
 catch (  QiniuException e) {
    try {
      return makeFile();
    }
 catch (    QiniuException e1) {
      throw e1;
    }
  }
}