Program: 4829
Project: 4829
Buggy source:
/** 
 * Assigns a white area or a grey area to a downloader. Sets the state, and checks if this downloader has been interrupted.
 * @param dloader The downloader to which this method assigns eithera grey area or white area.
 * @param refSleepTime this parameter is used for pass by reference, thismethod puts the minPollTime as the 0th element of this array.
 * @return 0 ifNoSuchElement, TryAgainLater, FileNotFound, NotSharing, Stopped, Misc IOE otherwise if queued return 1 otherwise if connected successfully return 2
 */
private int assignAndRequest(HTTPDownloader dloader,int[] refSleepTime){
synchronized (stealLock) {
    boolean updateNeeded=true;
    try {
      if (needed.size() > 0)       assignWhite(dloader);
 else {
        updateNeeded=false;
        assignGrey(dloader);
      }
      updateNeeded=false;
    }
 catch (    NoSuchElementException nsex) {
      Assert.that(updateNeeded == false,"String_Node_Str");
      debug("String_Node_Str" + dloader);
synchronized (this) {
        files.add(dloader.getRemoteFileDesc());
      }
      return 0;
    }
catch (    TryAgainLaterException talx) {
      debug("String_Node_Str" + dloader);
synchronized (this) {
        busy.add(dloader.getRemoteFileDesc());
      }
      return 0;
    }
catch (    FileNotFoundException fnfx) {
      debug("String_Node_Str" + dloader);
      return 0;
    }
catch (    NotSharingException nsx) {
      debug("String_Node_Str" + dloader);
      return 0;
    }
catch (    QueuedException qx) {
      debug("String_Node_Str" + dloader);
      refSleepTime[0]=qx.getMinPollTime() * 1000 + 1000;
synchronized (this) {
        if (dloaders.size() == 0) {
          setState(REMOTE_QUEUED);
        }
        int oldPos=queuePosition.equals("String_Node_Str") ? Integer.MAX_VALUE : Integer.parseInt(queuePosition);
        int newPos=qx.getQueuePosition();
        queuePosition=oldPos < newPos ? "String_Node_Str" + oldPos : "String_Node_Str" + newPos;
      }
      return 1;
    }
catch (    IOException iox) {
      debug("String_Node_Str" + dloader);
      return 0;
    }
 finally {
      if (updateNeeded)       updateNeeded(dloader);
    }
synchronized (this) {
      setState(DOWNLOADING);
    }
    if (stopped) {
      debug("String_Node_Str");
      updateNeeded(dloader);
synchronized (this) {
        files.add(dloader.getRemoteFileDesc());
      }
      return 0;
    }
synchronized (this) {
      dloaders.add(dloader);
      chatList.addHost(dloader);
      browseList.addHost(dloader);
      addAlternateLocations(dloader.getAlternateLocations(),dloader.getRemoteFileDesc());
    }
    return 2;
  }
}

Fixed version (ground truth):
/** 
 * Assigns a white area or a grey area to a downloader. Sets the state, and checks if this downloader has been interrupted.
 * @param dloader The downloader to which this method assigns eithera grey area or white area.
 * @param refSleepTime this parameter is used for pass by reference, thismethod puts the minPollTime as the 0th element of this array.
 * @return 0 ifNoSuchElement, TryAgainLater, FileNotFound, NotSharing, Stopped, Misc IOE otherwise if queued return 1 otherwise if connected successfully return 2
 */
private int assignAndRequest(HTTPDownloader dloader,int[] refSleepTime){
synchronized (stealLock) {
    boolean updateNeeded=true;
    try {
      if (needed.size() > 0)       assignWhite(dloader);
 else {
        updateNeeded=false;
        assignGrey(dloader);
      }
      updateNeeded=false;
    }
 catch (    NoSuchElementException nsex) {
      Assert.that(updateNeeded == false,"String_Node_Str");
      debug("String_Node_Str" + dloader);
synchronized (this) {
        files.add(dloader.getRemoteFileDesc());
      }
      return 0;
    }
catch (    TryAgainLaterException talx) {
      debug("String_Node_Str" + dloader);
synchronized (this) {
        busy.add(dloader.getRemoteFileDesc());
      }
      return 0;
    }
catch (    FileNotFoundException fnfx) {
      debug("String_Node_Str" + dloader);
      return 0;
    }
catch (    NotSharingException nsx) {
      debug("String_Node_Str" + dloader);
      return 0;
    }
catch (    QueuedException qx) {
      debug("String_Node_Str" + dloader);
      refSleepTime[0]=qx.getMinPollTime() * 1000 + 1000;
synchronized (this) {
        if (dloaders.size() == 0) {
          setState(REMOTE_QUEUED);
        }
        int oldPos=queuePosition.equals("String_Node_Str") ? Integer.MAX_VALUE : Integer.parseInt(queuePosition);
        int newPos=qx.getQueuePosition();
        queuePosition=oldPos < newPos ? "String_Node_Str" + oldPos : "String_Node_Str" + newPos;
      }
      return 1;
    }
catch (    IOException iox) {
      debug("String_Node_Str" + dloader);
      return 0;
    }
 finally {
synchronized (this) {
        addAlternateLocations(dloader.getAlternateLocations(),dloader.getRemoteFileDesc());
      }
      if (updateNeeded)       updateNeeded(dloader);
    }
synchronized (this) {
      setState(DOWNLOADING);
    }
    if (stopped) {
      debug("String_Node_Str");
      updateNeeded(dloader);
synchronized (this) {
        files.add(dloader.getRemoteFileDesc());
      }
      return 0;
    }
synchronized (this) {
      dloaders.add(dloader);
      chatList.addHost(dloader);
      browseList.addHost(dloader);
    }
    return 2;
  }
}