Program: 4332
Project: 4332
Buggy source:
/** 
 * Initializes a ManagedDownloader read from disk. Also used for internally initializing or resuming a normal download; there is no need to explicitly call this method in that case. After the call, this is in the queued state, at least for the moment.
 * @requires this is uninitialized or stopped, and allFiles, and incompleteFileManager are set
 * @modifies everything but the above fields 
 * @param deserialized True if this downloader is being initialized after being read from disk, false otherwise.
 */
public void initialize(DownloadManager manager,FileManager fileManager,DownloadCallback callback){
  this.manager=manager;
  this.fileManager=fileManager;
  this.callback=callback;
  currentRFDs=new HashSet();
  _activeWorkers=new LinkedList();
  _workers=new ArrayList();
  queuedWorkers=new HashMap();
  chatList=new DownloadChatList();
  browseList=new DownloadBrowseHostList();
  stealLock=new Object();
  stopped=false;
  paused=false;
  setState(QUEUED);
  pushObservers=Collections.synchronizedMap(new HashMap());
  corruptState=NOT_CORRUPT_STATE;
  corruptStateLock=new Object();
  altLock=new Object();
  numMeasures=0;
  averageBandwidth=0f;
  queuePosition=Integer.MAX_VALUE;
  queuedVendor="String_Node_Str";
  triedLocatingSources=false;
  ranker=getSourceRanker(null);
  ranker.setMeshHandler(this);
  if (downloadSHA1 == null)   downloadSHA1=(URN)propertiesMap.get(SHA1_URN);
synchronized (this) {
    for (Iterator iter=cachedRFDs.iterator(); iter.hasNext() && downloadSHA1 == null; ) {
      RemoteFileDesc rfd=(RemoteFileDesc)iter.next();
      downloadSHA1=rfd.getSHA1Urn();
    }
  }
  if (downloadSHA1 != null) {
    RouterService.getAltlocManager().addListener(downloadSHA1,this);
    propertiesMap.put(SHA1_URN,downloadSHA1);
  }
  verifyAllFiles();
synchronized (altLock) {
    validAlts=new HashSet();
    invalidAlts=new FixedSizeExpiringSet(1000,60 * 60 * 1000L);
    recentInvalidAlts=new FixedSizeExpiringSet(10,10 * 60 * 1000L);
  }
synchronized (this) {
    if (shouldInitAltLocs(deserializedFromDisk)) {
      initializeAlternateLocations();
    }
  }
  try {
    initializeIncompleteFile();
    initializeVerifyingFile();
  }
 catch (  IOException bad) {
    setState(DISK_PROBLEM);
    return;
  }
  setState(QUEUED);
}

Fixed version (ground truth):
/** 
 * Initializes a ManagedDownloader read from disk. Also used for internally initializing or resuming a normal download; there is no need to explicitly call this method in that case. After the call, this is in the queued state, at least for the moment.
 * @requires this is uninitialized or stopped, and allFiles, and incompleteFileManager are set
 * @modifies everything but the above fields 
 * @param deserialized True if this downloader is being initialized after being read from disk, false otherwise.
 */
public void initialize(DownloadManager manager,FileManager fileManager,DownloadCallback callback){
  this.manager=manager;
  this.fileManager=fileManager;
  this.callback=callback;
  currentRFDs=new HashSet();
  _activeWorkers=new LinkedList();
  _workers=new ArrayList();
  queuedWorkers=new HashMap();
  chatList=new DownloadChatList();
  browseList=new DownloadBrowseHostList();
  stealLock=new Object();
  stopped=false;
  paused=false;
  setState(QUEUED);
  pushes=new PushList();
  corruptState=NOT_CORRUPT_STATE;
  corruptStateLock=new Object();
  altLock=new Object();
  numMeasures=0;
  averageBandwidth=0f;
  queuePosition=Integer.MAX_VALUE;
  queuedVendor="String_Node_Str";
  triedLocatingSources=false;
  ranker=getSourceRanker(null);
  ranker.setMeshHandler(this);
  if (downloadSHA1 == null)   downloadSHA1=(URN)propertiesMap.get(SHA1_URN);
synchronized (this) {
    for (Iterator iter=cachedRFDs.iterator(); iter.hasNext() && downloadSHA1 == null; ) {
      RemoteFileDesc rfd=(RemoteFileDesc)iter.next();
      downloadSHA1=rfd.getSHA1Urn();
    }
  }
  if (downloadSHA1 != null) {
    RouterService.getAltlocManager().addListener(downloadSHA1,this);
    propertiesMap.put(SHA1_URN,downloadSHA1);
  }
  verifyAllFiles();
synchronized (altLock) {
    validAlts=new HashSet();
    invalidAlts=new FixedSizeExpiringSet(1000,60 * 60 * 1000L);
    recentInvalidAlts=new FixedSizeExpiringSet(10,10 * 60 * 1000L);
  }
synchronized (this) {
    if (shouldInitAltLocs(deserializedFromDisk)) {
      initializeAlternateLocations();
    }
  }
  try {
    initializeIncompleteFile();
    initializeVerifyingFile();
  }
 catch (  IOException bad) {
    setState(DISK_PROBLEM);
    return;
  }
  setState(QUEUED);
}