Program: 4655
Project: 4655
Buggy source:
/** 
 * Attempts to upload the given file for the given uploader.  May instead  reject or queue the upload.
 * @param uploader the uploader for this file, which MUST be connected
 * @param giveSlot whether the upload already has the slot for this fileIf false, the usual queueing rules apply.
 * @exception IOException if checkAndQueue throws an IOException, whichmeans that the GET request came too early for the queued uploader
 */
private int doSingleUpload(Uploader uploader,Socket socket,String host,int index,boolean giveSlot) throws IOException {
  long startTime=-1;
  debug(uploader + "String_Node_Str");
  boolean isBHUploader=(uploader.getState() == Uploader.BROWSE_HOST);
  boolean updateCheck=(uploader.getState() == Uploader.UPDATE_FILE);
  int queued=-1;
  if (!isBHUploader && !updateCheck) {
    if (uploader.getState() == Uploader.CONNECTING) {
      queued=checkAndQueue(uploader,host,socket,giveSlot);
      debug(uploader + "String_Node_Str" + queued);
      Assert.that(queued != -1);
    }
    if (uploader.getMethod() != HTTPRequestMethod.HEAD) {
      RouterService.getCallback().addUpload(uploader);
      FileDesc fd=uploader.getFileDesc();
      if (fd != null) {
        fd.incrementAttemptedUploads();
        RouterService.getCallback().handleSharedFileUpdate(fd.getFile());
      }
    }
  }
  if (queued == QUEUED) {
    socket.setSoTimeout(MAX_POLL_TIME);
    uploader.setState(Uploader.QUEUED);
  }
 else   if (queued == ACCEPTED) {
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 && uploader.getMethod() != HTTPRequestMethod.HEAD) {
      FileDesc fd=uploader.getFileDesc();
      if (fd != null) {
        fd.incrementCompletedUploads();
        RouterService.getCallback().handleSharedFileUpdate(fd.getFile());
      }
    }
  }
  long finishTime=System.currentTimeMillis();
synchronized (UploadManager.this) {
    if (startTime > 0)     reportUploadSpeed(finishTime - startTime,uploader.amountUploaded());
    return queued;
  }
}

Fixed version (ground truth):
/** 
 * Attempts to upload the given file for the given uploader.  May instead  reject or queue the upload.
 * @param uploader the uploader for this file, which MUST be connected
 * @param giveSlot whether the upload already has the slot for this fileIf false, the usual queueing rules apply.
 * @exception IOException if checkAndQueue throws an IOException, whichmeans that the GET request came too early for the queued uploader
 */
private int doSingleUpload(Uploader uploader,Socket socket,String host,int index,boolean giveSlot) throws IOException {
  long startTime=-1;
  debug(uploader + "String_Node_Str");
  int queued=-1;
  if (!shouldBypassQueue(uploader)) {
    if (uploader.getState() == Uploader.CONNECTING) {
      queued=checkAndQueue(uploader,host,socket,giveSlot);
      debug(uploader + "String_Node_Str" + queued);
      Assert.that(queued != -1);
    }
    if (shouldShowInGUI(uploader)) {
      RouterService.getCallback().addUpload(uploader);
      FileDesc fd=uploader.getFileDesc();
      if (fd != null) {
        fd.incrementAttemptedUploads();
        RouterService.getCallback().handleSharedFileUpdate(fd.getFile());
      }
    }
  }
  if (queued == QUEUED) {
    socket.setSoTimeout(MAX_POLL_TIME);
    uploader.setState(Uploader.QUEUED);
  }
 else   if (queued == ACCEPTED) {
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 (shouldShowInGUI(uploader)) {
      FileDesc fd=uploader.getFileDesc();
      if (fd != null) {
        fd.incrementCompletedUploads();
        RouterService.getCallback().handleSharedFileUpdate(fd.getFile());
      }
    }
  }
  long finishTime=System.currentTimeMillis();
synchronized (UploadManager.this) {
    if (startTime > 0)     reportUploadSpeed(finishTime - startTime,uploader.amountUploaded());
    return queued;
  }
}