Program: 4691
Project: 4691
Buggy source:
/** 
 * Tests that the progress is retained for deserialized downloaders. 
 */
public void testSerializedProgress() throws Exception {
  DownloadManager manager=new DownloadManagerStub();
  FileManager fileman=new FileManagerStub();
  ActivityCallback callback=new ActivityCallbackStub();
  IncompleteFileManager ifm=new IncompleteFileManager();
  RemoteFileDesc rfd=newRFD("String_Node_Str");
  File incompleteFile=ifm.getFile(rfd);
  int amountDownloaded=100;
  VerifyingFile vf=new VerifyingFile(false);
  vf.addInterval(new Interval(0,amountDownloaded - 1));
  ifm.addEntry(incompleteFile,vf);
  ManagedDownloader downloader=new ManagedDownloader(new RemoteFileDesc[]{rfd},ifm);
  downloader.initialize(manager,fileman,callback);
  try {
    Thread.sleep(200);
  }
 catch (  InterruptedException e) {
  }
  assertEquals(amountDownloaded,downloader.getAmountRead());
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    ObjectOutputStream out=new ObjectOutputStream(baos);
    out.writeObject(downloader);
    out.flush();
    out.close();
    downloader.stop();
    ObjectInputStream in=new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    downloader=(ManagedDownloader)in.readObject();
    in.close();
    downloader.initialize(manager,fileman,callback);
  }
 catch (  IOException e) {
    fail("String_Node_Str",e);
  }
  try {
    Thread.sleep(200);
  }
 catch (  InterruptedException e) {
  }
  assertEquals(amountDownloaded,downloader.getAmountRead());
  downloader.stop();
  try {
    Thread.sleep(1000);
  }
 catch (  InterruptedException e) {
  }
}

Fixed version (ground truth):
/** 
 * Tests that the progress is retained for deserialized downloaders. 
 */
public void testSerializedProgress() throws Exception {
  DownloadManager manager=new DownloadManagerStub();
  FileManager fileman=new FileManagerStub();
  ActivityCallback callback=new ActivityCallbackStub();
  IncompleteFileManager ifm=new IncompleteFileManager();
  RemoteFileDesc rfd=newRFD("String_Node_Str");
  File incompleteFile=ifm.getFile(rfd);
  int amountDownloaded=100;
  VerifyingFile vf=new VerifyingFile(false);
  vf.addInterval(new Interval(0,amountDownloaded - 1));
  ifm.addEntry(incompleteFile,vf);
  ManagedDownloader downloader=new ManagedDownloader("String_Node_Str",new RemoteFileDesc[]{rfd},ifm);
  downloader.initialize(manager,fileman,callback);
  try {
    Thread.sleep(200);
  }
 catch (  InterruptedException e) {
  }
  assertEquals(amountDownloaded,downloader.getAmountRead());
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    ObjectOutputStream out=new ObjectOutputStream(baos);
    out.writeObject(downloader);
    out.flush();
    out.close();
    downloader.stop();
    ObjectInputStream in=new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    downloader=(ManagedDownloader)in.readObject();
    in.close();
    downloader.initialize(manager,fileman,callback);
  }
 catch (  IOException e) {
    fail("String_Node_Str",e);
  }
  try {
    Thread.sleep(200);
  }
 catch (  InterruptedException e) {
  }
  assertEquals(amountDownloaded,downloader.getAmountRead());
  downloader.stop();
  try {
    Thread.sleep(1000);
  }
 catch (  InterruptedException e) {
  }
}