Program: 4497
Project: 4497
Buggy source:
public void testLegacy(){
  RemoteFileDescGrouper grouper=null;
  RemoteFileDesc[] allFiles=null;
  Iterator iter=null;
  List list=null;
  allFiles=new RemoteFileDesc[]{rf3,rf2,rf1,rf4};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf1));
  assertTrue(list.contains(rf2));
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf3));
  assertTrue(list.contains(rf4));
  assertTrue(!iter.hasNext());
  allFiles=new RemoteFileDesc[]{rf3};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  assertEquals(1,grouper.add(rf4,false));
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf3));
  assertTrue(list.contains(rf4));
  allFiles=new RemoteFileDesc[]{rf3};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  list=(List)iter.next();
  assertEquals(1,list.size());
  assertTrue(list.contains(rf3));
  assertEquals(0,grouper.add(rf1,false));
  list=(List)iter.next();
  assertEquals(1,list.size());
  assertTrue(list.contains(rf1));
  VerifyingFile vf=new VerifyingFile(false);
  vf.addInterval(new Interval(0,1008));
  ifm.addEntry(ifm.getFile(rf3),vf);
  allFiles=new RemoteFileDesc[]{rf3,rf2,rf1,rf4};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf3));
  assertTrue(list.contains(rf4));
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf1));
  assertTrue(list.contains(rf2));
  assertTrue(!iter.hasNext());
  allFiles=new RemoteFileDesc[]{rf3};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  list=(List)iter.next();
  assertEquals(1,list.size());
  assertTrue(list.contains(rf3));
  list.remove(rf3);
  assertEquals(0,list.size());
  assertEquals(1,grouper.add(rf4,false));
  assertEquals(1,list.size());
  assertTrue(list.contains(rf4));
}

Fixed version (ground truth):
public void testLegacy() throws Throwable {
  RemoteFileDescGrouper grouper=null;
  RemoteFileDesc[] allFiles=null;
  Iterator iter=null;
  List list=null;
  allFiles=new RemoteFileDesc[]{rf3,rf2,rf1,rf4};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf1));
  assertTrue(list.contains(rf2));
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf3));
  assertTrue(list.contains(rf4));
  assertTrue(!iter.hasNext());
  allFiles=new RemoteFileDesc[]{rf3};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  assertEquals(1,grouper.add(rf4,false));
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf3));
  assertTrue(list.contains(rf4));
  allFiles=new RemoteFileDesc[]{rf3};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  list=(List)iter.next();
  assertEquals(1,list.size());
  assertTrue(list.contains(rf3));
  assertEquals(0,grouper.add(rf1,false));
  list=(List)iter.next();
  assertEquals(1,list.size());
  assertTrue(list.contains(rf1));
  VerifyingFile vf=new VerifyingFile(false);
  vf.addInterval(new Interval(0,1008));
  ifm.addEntry(ifm.getFile(rf3),vf);
  allFiles=new RemoteFileDesc[]{rf3,rf2,rf1,rf4};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf3));
  assertTrue(list.contains(rf4));
  list=(List)iter.next();
  assertEquals(2,list.size());
  assertTrue(list.contains(rf1));
  assertTrue(list.contains(rf2));
  assertTrue(!iter.hasNext());
  allFiles=new RemoteFileDesc[]{rf3};
  grouper=new RemoteFileDescGrouper(allFiles,ifm);
  iter=grouper.buckets();
  list=(List)iter.next();
  assertEquals(1,list.size());
  assertTrue(list.contains(rf3));
  list.remove(rf3);
  assertEquals(0,list.size());
  assertEquals(1,grouper.add(rf4,false));
  assertEquals(1,list.size());
  assertTrue(list.contains(rf4));
}