Program: 4588
Project: 4588
Buggy source:
/** 
 * Top level method of the thread. Calls three methods  a. Establish a TCP Connection. b. Assign this thread a part of the file, and do HTTP handshaking c. get the file. Each of these steps can run into errors, which have to be dealt with differently.
 * @return true if this worker thread should notify, false otherwise.currently this method returns false iff NSEEx is  thrown. 
 */
private boolean connectAndDownload(RemoteFileDesc rfd){
  HTTPDownloader dloader=null;
  dloader=establishConnection(rfd);
  if (dloader == null)   return true;
  if (validAlts != null) {
    Iterator iter=validAlts.iterator();
synchronized (validAlts) {
      int count=0;
      while (iter.hasNext() && count < 10) {
        dloader.addSuccessfulAltLoc((AlternateLocation)iter.next());
        count++;
      }
    }
  }
  boolean http11=true;
  while (http11) {
    int connected;
    http11=rfd.isHTTP11();
    while (true) {
      int[] a={-1,-1};
      connected=assignAndRequest(dloader,a,http11);
      boolean addQueued=killQueuedIfNecessary(connected,a[1]);
      if (connected == 4)       continue;
      if (connected != 1)       break;
      if (connected == 1 && !addQueued) {
        return true;
      }
      if (connected == 1) {
        Assert.that(a[0] > -1 && a[1] > -1,"String_Node_Str");
        try {
          Thread.sleep(a[0]);
        }
 catch (        InterruptedException ix) {
          debug("String_Node_Str" + "String_Node_Str" + dloader);
          queuedThreads.remove(Thread.currentThread());
          dloader.stop();
          return true;
        }
      }
 else       Assert.that(false,"String_Node_Str");
    }
synchronized (this) {
      queuedThreads.remove(Thread.currentThread());
    }
    Assert.that(connected == 0 || connected == 2 || connected == 3,"String_Node_Str" + connected);
    if (connected == 0) {
      dloader.stop();
      return true;
    }
 else     if (connected == 3) {
      dloader.stop();
      return false;
    }
    boolean downloadOK=doDownload(dloader,http11);
    if (!downloadOK)     break;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Top level method of the thread. Calls three methods  a. Establish a TCP Connection. b. Assign this thread a part of the file, and do HTTP handshaking c. get the file. Each of these steps can run into errors, which have to be dealt with differently.
 * @return true if this worker thread should notify, false otherwise.currently this method returns false iff NSEEx is  thrown. 
 */
private boolean connectAndDownload(RemoteFileDesc rfd){
  HTTPDownloader dloader=null;
  dloader=establishConnection(rfd);
  if (dloader == null)   return true;
  if (validAlts != null) {
    Iterator iter=validAlts.iterator();
synchronized (validAlts) {
      int count=0;
      while (iter.hasNext() && count < 10) {
        dloader.addSuccessfulAltLoc((AlternateLocation)iter.next());
        count++;
      }
    }
  }
  boolean http11=true;
  while (http11) {
    int connected;
    http11=rfd.isHTTP11();
    while (true) {
      int[] qInfo={-1,-1};
      connected=assignAndRequest(dloader,qInfo,http11);
      boolean addQueued=killQueuedIfNecessary(connected,qInfo[1]);
      if (connected == 4)       continue;
      if (connected != 1)       break;
      if (connected == 1 && !addQueued) {
        return true;
      }
      if (connected == 1) {
        Assert.that(qInfo[0] > -1 && qInfo[1] > -1,"String_Node_Str");
        try {
          Thread.sleep(qInfo[0]);
        }
 catch (        InterruptedException ix) {
          debug("String_Node_Str" + "String_Node_Str" + dloader);
          queuedThreads.remove(Thread.currentThread());
          dloader.stop();
          return true;
        }
      }
 else       Assert.that(false,"String_Node_Str");
    }
synchronized (this) {
      queuedThreads.remove(Thread.currentThread());
    }
    Assert.that(connected == 0 || connected == 2 || connected == 3,"String_Node_Str" + connected);
    if (connected == 0) {
      dloader.stop();
      return true;
    }
 else     if (connected == 3) {
      dloader.stop();
      return false;
    }
    boolean downloadOK=doDownload(dloader,http11);
    if (!downloadOK)     break;
  }
  return true;
}