Program: 29556
Project: 29556
Buggy source:
/** 
 * In this method, we got the Content-Length, with the TemporaryFile length, we can calculate the actually size of the whole file, if TemporaryFile not exists, we'll take the store file length then compare to actually size, and if equals, we consider this download was already done. We used   {@link RandomAccessFile} to continue download, when download success,the TemporaryFile will be rename to StoreFile.
 */
@Override public byte[] handleResponse(HttpResponse response,Delivery delivery) throws IOException, ServerError {
  HttpEntity entity=response.getEntity();
  long fileSize=entity.getContentLength();
  if (fileSize <= 0) {
    NetroidLog.d("String_Node_Str");
  }
  long downloadedSize=mTemporaryFile.length();
  boolean isSupportRange=HttpUtils.isSupportRange(response);
  if (isSupportRange) {
    fileSize+=downloadedSize;
    String realRangeValue=HttpUtils.getHeader(response,"String_Node_Str");
    if (!TextUtils.isEmpty(realRangeValue)) {
      String assumeRangeValue="String_Node_Str" + downloadedSize + "String_Node_Str"+ (fileSize - 1);
      if (TextUtils.indexOf(realRangeValue,assumeRangeValue) == -1) {
        throw new IllegalStateException("String_Node_Str" + assumeRangeValue + "String_Node_Str"+ realRangeValue+ "String_Node_Str"+ "String_Node_Str"+ mTemporaryFile+ "String_Node_Str");
      }
    }
  }
  if (fileSize > 0 && mStoreFile.length() == fileSize) {
    mStoreFile.renameTo(mTemporaryFile);
    delivery.postDownloadProgress(this,fileSize,fileSize);
    return null;
  }
  RandomAccessFile tmpFileRaf=new RandomAccessFile(mTemporaryFile,"String_Node_Str");
  if (isSupportRange) {
    tmpFileRaf.seek(downloadedSize);
  }
 else {
    tmpFileRaf.setLength(0);
    downloadedSize=0;
  }
  try {
    InputStream in=entity.getContent();
    if (HttpUtils.isGzipContent(response) && !(in instanceof GZIPInputStream)) {
      in=new GZIPInputStream(in);
    }
    byte[] buffer=new byte[6 * 1024];
    int offset;
    while ((offset=in.read(buffer)) != -1) {
      tmpFileRaf.write(buffer,0,offset);
      downloadedSize+=offset;
      delivery.postDownloadProgress(this,fileSize,downloadedSize);
      if (isCanceled()) {
        delivery.postCancel(this);
        break;
      }
    }
  }
  finally {
    try {
      if (entity != null)       entity.consumeContent();
    }
 catch (    Exception e) {
      NetroidLog.v("String_Node_Str");
    }
    tmpFileRaf.close();
  }
  return null;
}

Fixed version (ground truth):
/** 
 * In this method, we got the Content-Length, with the TemporaryFile length, we can calculate the actually size of the whole file, if TemporaryFile not exists, we'll take the store file length then compare to actually size, and if equals, we consider this download was already done. We used   {@link RandomAccessFile} to continue download, when download success,the TemporaryFile will be rename to StoreFile.
 */
@Override public byte[] handleResponse(HttpResponse response,Delivery delivery) throws IOException, ServerError {
  HttpEntity entity=response.getEntity();
  long fileSize=entity.getContentLength();
  if (fileSize <= 0) {
    NetroidLog.d("String_Node_Str");
  }
  long downloadedSize=mTemporaryFile.length();
  boolean isSupportRange=HttpUtils.isSupportRange(response);
  if (isSupportRange) {
    fileSize+=downloadedSize;
    String realRangeValue=HttpUtils.getHeader(response,"String_Node_Str");
    if (!TextUtils.isEmpty(realRangeValue)) {
      String assumeRangeValue="String_Node_Str" + downloadedSize + "String_Node_Str"+ (fileSize - 1);
      if (TextUtils.indexOf(realRangeValue,assumeRangeValue) == -1) {
        throw new IllegalStateException("String_Node_Str" + assumeRangeValue + "String_Node_Str"+ realRangeValue+ "String_Node_Str"+ "String_Node_Str"+ mTemporaryFile+ "String_Node_Str");
      }
    }
  }
  if (fileSize > 0 && mStoreFile.length() == fileSize) {
    mStoreFile.renameTo(mTemporaryFile);
    delivery.postDownloadProgress(this,fileSize,fileSize);
    return null;
  }
  RandomAccessFile tmpFileRaf=new RandomAccessFile(mTemporaryFile,"String_Node_Str");
  if (isSupportRange) {
    tmpFileRaf.seek(downloadedSize);
  }
 else {
    tmpFileRaf.setLength(0);
    downloadedSize=0;
  }
  try {
    InputStream in=entity.getContent();
    if (HttpUtils.isGzipContent(response) && !(in instanceof GZIPInputStream)) {
      in=new GZIPInputStream(in);
    }
    byte[] buffer=new byte[6 * 1024];
    int offset;
    while ((offset=in.read(buffer)) != -1) {
      tmpFileRaf.write(buffer,0,offset);
      downloadedSize+=offset;
      delivery.postDownloadProgress(this,fileSize,downloadedSize);
      if (isCanceled()) {
        delivery.postCancel(this);
        break;
      }
    }
  }
  finally {
    try {
      entity.consumeContent();
    }
 catch (    Exception e) {
      NetroidLog.v("String_Node_Str");
    }
    tmpFileRaf.close();
  }
  return null;
}