Program: 4359
Project: 4359
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);
  miniRFDToLock=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 (cachedRFDs.size() > 0 && downloadSHA1 == null) {
    for (Iterator iter=cachedRFDs.iterator(); iter.hasNext() && downloadSHA1 == null; ) {
      RemoteFileDesc rfd=(RemoteFileDesc)iter.next();
      downloadSHA1=rfd.getSHA1Urn();
      RouterService.getAltlocManager().addListener(downloadSHA1,this);
    }
  }
  verifyAllFiles();
  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);
  miniRFDToLock=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);
  for (Iterator iter=cachedRFDs.iterator(); iter.hasNext() && downloadSHA1 == null; ) {
    RemoteFileDesc rfd=(RemoteFileDesc)iter.next();
    downloadSHA1=rfd.getSHA1Urn();
    RouterService.getAltlocManager().addListener(downloadSHA1,this);
  }
  if (downloadSHA1 != null)   propertiesMap.put(SHA1_URN,downloadSHA1);
  verifyAllFiles();
  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);
}