Program: 4818
Project: 4818
Buggy source:
/** 
 * Does some book-keeping and makes the downloader, start the download
 * @param uploader This method assumes that uploader is connected.
 * @exception IOException thrown if insertAndTest throws an IOException
 */
private boolean doSingleUpload(Uploader uploader,Socket socket,String host,int index) throws IOException {
  long startTime=-1;
  debug(uploader + "String_Node_Str");
  boolean isBHUploader=(uploader.getState() == Uploader.BROWSE_HOST);
  int queued=-1;
  boolean ret=false;
  if (!isBHUploader) {
    queued=insertAndTest(uploader,host,socket);
    debug(uploader + "String_Node_Str" + queued);
    Assert.that(queued != -1);
    _callback.addUpload(uploader);
    FileDesc fd=uploader.getFileDesc();
    if (fd != null) {
      fd.incrementAttemptedUploads();
      _callback.handleSharedFileUpdate(fd.getFile());
    }
  }
  if (queued == 1) {
    socket.setSoTimeout(MAX_POLL_TIME);
    uploader.setState(Uploader.QUEUED);
    ret=true;
  }
 else   if (queued == 2) {
synchronized (this) {
      uploader.setState(Uploader.CONNECTING);
      _activeUploadList.add(uploader);
    }
  }
  startTime=System.currentTimeMillis();
  uploader.writeResponse();
  debug(uploader + "String_Node_Str");
  if (uploader.getState() == Uploader.UPLOADING || uploader.getState() == Uploader.CONNECTING) {
    uploader.setState(Uploader.INTERRUPTED);
  }
  if (uploader.getState() == Uploader.COMPLETE) {
    _hadSuccesfulUpload=true;
    if (!isBHUploader) {
      FileDesc fd=uploader.getFileDesc();
      if (fd != null) {
        fd.incrementCompletedUploads();
        _callback.handleSharedFileUpdate(fd.getFile());
      }
    }
  }
  long finishTime=System.currentTimeMillis();
synchronized (UploadManager.this) {
    if (startTime > 0)     reportUploadSpeed(finishTime - startTime,uploader.amountUploaded());
    removeFromList(uploader);
    if (!isBHUploader)     _callback.removeUpload(uploader);
    return ret;
  }
}

Fixed version (ground truth):
/** 
 * Does some book-keeping and makes the downloader, start the download
 * @param uploader This method assumes that uploader is connected.
 * @exception IOException thrown if insertAndTest throws an IOException
 */
private boolean doSingleUpload(Uploader uploader,Socket socket,String host,int index) throws IOException {
  long startTime=-1;
  debug(uploader + "String_Node_Str");
  boolean isBHUploader=(uploader.getState() == Uploader.BROWSE_HOST);
  int queued=-1;
  boolean ret=false;
  if (!isBHUploader) {
    if (uploader.getState() == Uploader.CONNECTING) {
      queued=insertAndTest(uploader,host,socket);
      debug(uploader + "String_Node_Str" + queued);
      Assert.that(queued != -1);
    }
    _callback.addUpload(uploader);
    FileDesc fd=uploader.getFileDesc();
    if (fd != null) {
      fd.incrementAttemptedUploads();
      _callback.handleSharedFileUpdate(fd.getFile());
    }
  }
  if (queued == 1) {
    socket.setSoTimeout(MAX_POLL_TIME);
    uploader.setState(Uploader.QUEUED);
    ret=true;
  }
 else   if (queued == 2) {
synchronized (this) {
      uploader.setState(Uploader.CONNECTING);
      _activeUploadList.add(uploader);
    }
  }
  startTime=System.currentTimeMillis();
  uploader.writeResponse();
  debug(uploader + "String_Node_Str");
  if (uploader.getState() == Uploader.UPLOADING || uploader.getState() == Uploader.CONNECTING) {
    uploader.setState(Uploader.INTERRUPTED);
  }
  if (uploader.getState() == Uploader.COMPLETE) {
    _hadSuccesfulUpload=true;
    if (!isBHUploader) {
      FileDesc fd=uploader.getFileDesc();
      if (fd != null) {
        fd.incrementCompletedUploads();
        _callback.handleSharedFileUpdate(fd.getFile());
      }
    }
  }
  long finishTime=System.currentTimeMillis();
synchronized (UploadManager.this) {
    if (startTime > 0)     reportUploadSpeed(finishTime - startTime,uploader.amountUploaded());
    removeFromList(uploader);
    if (!isBHUploader)     _callback.removeUpload(uploader);
    return ret;
  }
}