Program: 4446
Project: 4446
Buggy source:
public void testBusyDownloadLocatesSources() throws Exception {
  keepAllAlive(testUP);
  drainAll();
  DatagramPacket pack=null;
  Message m=null;
  byte[] guid=RouterService.newQueryGUID();
  RouterService.query(guid,"String_Node_Str");
  ((MyCallback)getCallback()).setGUID(new GUID(guid));
  QueryRequest qr=(QueryRequest)getFirstInstanceOfMessageType(testUP[0],QueryRequest.class);
  assertNotNull(qr);
  assertTrue(qr.desiresOutOfBandReplies());
  for (int i=0; i < testUP.length; i++) {
    Response[] res=new Response[200];
    for (int j=0; j < res.length; j++)     res[j]=new Response(10 + j + i,10 + j + i,"String_Node_Str" + j + i);
    m=new QueryReply(qr.getGUID(),(byte)1,6355,myIP(),0,res,GUID.makeGuid(),new byte[0],false,false,true,true,false,false,null);
    testUP[i].send(m);
    testUP[i].flush();
  }
  final int UPLOADER_PORT=10000;
  TestUploader uploader=new TestUploader("String_Node_Str",UPLOADER_PORT);
  uploader.setBusy(true);
  URN urn=URN.createSHA1Urn("String_Node_Str");
  Set urns=new HashSet();
  urns.add(urn);
  RemoteFileDesc rfd=new RemoteFileDesc("String_Node_Str",UPLOADER_PORT,1,"String_Node_Str",10,GUID.makeGuid(),1,false,3,false,null,urns,false,false,"String_Node_Str",0,new HashSet());
  Thread.sleep(1500);
  for (int i=0; i < UDP_ACCESS.length; i++) {
    ReplyNumberVendorMessage vm=new ReplyNumberVendorMessage(new GUID(qr.getGUID()),i + 1);
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    vm.write(baos);
    pack=new DatagramPacket(baos.toByteArray(),baos.toByteArray().length,testUP[0].getInetAddress(),SERVER_PORT);
    UDP_ACCESS[i].send(pack);
  }
  Thread.sleep(500);
{
    Map _bypassedResults=(Map)PrivilegedAccessor.getValue(RouterService.getMessageRouter(),"String_Node_Str");
    assertNotNull(_bypassedResults);
    assertEquals(1,_bypassedResults.size());
    Set endpoints=(Set)_bypassedResults.get(new GUID(qr.getGUID()));
    assertNotNull(endpoints);
    assertEquals(UDP_ACCESS.length,endpoints.size());
  }
  long currTime=System.currentTimeMillis();
  Downloader downloader=RouterService.download(new RemoteFileDesc[]{rfd},false,new GUID(guid));
  Thread.sleep(10000);
  assertEquals(Downloader.ITERATIVE_GUESSING,downloader.getState());
  for (int i=0; i < UDP_ACCESS.length; i++) {
    boolean gotPing=false;
    while (!gotPing) {
      try {
        byte[] datagramBytes=new byte[1000];
        pack=new DatagramPacket(datagramBytes,1000);
        UDP_ACCESS[i].setSoTimeout(10000);
        UDP_ACCESS[i].receive(pack);
        InputStream in=new ByteArrayInputStream(pack.getData());
        m=Message.read(in);
        m.hop();
        if (m instanceof PingRequest)         gotPing=((PingRequest)m).isQueryKeyRequest();
      }
 catch (      InterruptedIOException iioe) {
        assertTrue("String_Node_Str" + i,false);
      }
    }
  }
  Thread.sleep(1000);
  assertEquals(Downloader.WAITING_FOR_RETRY,downloader.getState());
  ((MyCallback)getCallback()).clearGUID();
  downloader.stop();
  Thread.sleep(1000);
{
    Map _bypassedResults=(Map)PrivilegedAccessor.getValue(RouterService.getMessageRouter(),"String_Node_Str");
    assertNotNull(_bypassedResults);
    assertEquals(0,_bypassedResults.size());
    Set endpoints=(Set)_bypassedResults.get(new GUID(qr.getGUID()));
    assertNull(endpoints);
  }
}

Fixed version (ground truth):
public void testBusyDownloadLocatesSources() throws Exception {
  keepAllAlive(testUP);
  drainAll();
  DatagramPacket pack=null;
  Message m=null;
  byte[] guid=RouterService.newQueryGUID();
  RouterService.query(guid,"String_Node_Str");
  ((MyCallback)getCallback()).setGUID(new GUID(guid));
  QueryRequest qr=(QueryRequest)getFirstInstanceOfMessageType(testUP[0],QueryRequest.class);
  assertNotNull(qr);
  assertTrue(qr.desiresOutOfBandReplies());
  for (int i=0; i < testUP.length; i++) {
    Response[] res=new Response[200];
    for (int j=0; j < res.length; j++)     res[j]=new Response(10 + j + i,10 + j + i,"String_Node_Str" + j + i);
    m=new QueryReply(qr.getGUID(),(byte)1,6355,myIP(),0,res,GUID.makeGuid(),new byte[0],false,false,true,true,false,false,null);
    testUP[i].send(m);
    testUP[i].flush();
  }
  final int UPLOADER_PORT=10000;
  TestUploader uploader=new TestUploader("String_Node_Str",UPLOADER_PORT);
  uploader.setBusy(true);
  URN urn=URN.createSHA1Urn("String_Node_Str");
  Set urns=new HashSet();
  urns.add(urn);
  RemoteFileDesc rfd=new RemoteFileDesc("String_Node_Str",UPLOADER_PORT,1,"String_Node_Str",10,GUID.makeGuid(),1,false,3,false,null,urns,false,false,"String_Node_Str",0,new HashSet());
  Thread.sleep(1500);
  for (int i=0; i < UDP_ACCESS.length; i++) {
    ReplyNumberVendorMessage vm=new ReplyNumberVendorMessage(new GUID(qr.getGUID()),i + 1);
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    vm.write(baos);
    pack=new DatagramPacket(baos.toByteArray(),baos.toByteArray().length,testUP[0].getInetAddress(),SERVER_PORT);
    UDP_ACCESS[i].send(pack);
  }
  Thread.sleep(500);
{
    Map _bypassedResults=(Map)PrivilegedAccessor.getValue(RouterService.getMessageRouter(),"String_Node_Str");
    assertNotNull(_bypassedResults);
    assertEquals(1,_bypassedResults.size());
    Set endpoints=(Set)_bypassedResults.get(new GUID(qr.getGUID()));
    assertNotNull(endpoints);
    assertEquals(UDP_ACCESS.length,endpoints.size());
  }
  long currTime=System.currentTimeMillis();
  Downloader downloader=RouterService.download(new RemoteFileDesc[]{rfd},false,new GUID(guid));
  final int MAX_TRIES=60;
  for (int i=0; i <= MAX_TRIES; i++) {
    Thread.sleep(1000);
    if (downloader.getState() == Downloader.ITERATIVE_GUESSING)     break;
    if (i == MAX_TRIES)     fail("String_Node_Str");
  }
  for (int i=0; i < UDP_ACCESS.length; i++) {
    boolean gotPing=false;
    while (!gotPing) {
      try {
        byte[] datagramBytes=new byte[1000];
        pack=new DatagramPacket(datagramBytes,1000);
        UDP_ACCESS[i].setSoTimeout(10000);
        UDP_ACCESS[i].receive(pack);
        InputStream in=new ByteArrayInputStream(pack.getData());
        m=Message.read(in);
        m.hop();
        if (m instanceof PingRequest)         gotPing=((PingRequest)m).isQueryKeyRequest();
      }
 catch (      InterruptedIOException iioe) {
        assertTrue("String_Node_Str" + i,false);
      }
    }
  }
  Thread.sleep(1000);
  assertEquals(Downloader.WAITING_FOR_RETRY,downloader.getState());
  ((MyCallback)getCallback()).clearGUID();
  downloader.stop();
  Thread.sleep(1000);
{
    Map _bypassedResults=(Map)PrivilegedAccessor.getValue(RouterService.getMessageRouter(),"String_Node_Str");
    assertNotNull(_bypassedResults);
    assertEquals(0,_bypassedResults.size());
    Set endpoints=(Set)_bypassedResults.get(new GUID(qr.getGUID()));
    assertNull(endpoints);
  }
}