Program: 4367
Project: 4367
Buggy source:
/** 
 * Busy loop that listens on a port for udp messages and then logs them.
 */
private void udpLoop(int port){
  DatagramSocket socket=null;
  try {
    socket=new DatagramSocket(port);
    socket.setSoTimeout(1000);
    debug("String_Node_Str" + port);
  }
 catch (  SocketException e) {
    debug("String_Node_Str" + port);
    return;
  }
catch (  RuntimeException e) {
    debug("String_Node_Str" + port);
    return;
  }
  byte[] datagramBytes=new byte[BUFFER_SIZE];
  DatagramPacket datagram=new DatagramPacket(datagramBytes,BUFFER_SIZE);
  QueryKey.SecretKey key=QueryKey.generateSecretKey();
  QueryKey.SecretPad pad=QueryKey.generateSecretPad();
  while (shouldRun()) {
    try {
      socket.receive(datagram);
      byte[] data=datagram.getData();
      int length=datagram.getLength();
      try {
        InputStream in=new ByteArrayInputStream(data);
        Message message=Message.read(in);
        if (message == null)         continue;
        if (message instanceof PingRequest) {
          PingRequest pr=(PingRequest)message;
          pr.hop();
          if (pr.isQueryKeyRequest()) {
            QueryKey qk=QueryKey.getQueryKey(datagram.getAddress(),datagram.getPort(),key,pad);
            PingReply pRep=PingReply.createQueryKeyReply(pr.getGUID(),(byte)1,port,localhost,2,2,true,qk);
            pRep.hop();
            debug("String_Node_Str");
            QueryUnicaster.instance().handleQueryKeyPong(pRep);
          }
        }
synchronized (_messages) {
          _messages.add(message);
          _messages.notify();
        }
      }
 catch (      BadPacketException e) {
        continue;
      }
    }
 catch (    InterruptedIOException e) {
      continue;
    }
catch (    IOException e) {
      continue;
    }
  }
  debug("String_Node_Str" + port);
  socket.close();
}

Fixed version (ground truth):
/** 
 * Busy loop that listens on a port for udp messages and then logs them.
 */
private void udpLoop(int port){
  DatagramSocket socket=null;
  try {
    socket=new DatagramSocket(port);
    socket.setSoTimeout(1000);
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + port);
  }
 catch (  SocketException e) {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + port);
    return;
  }
catch (  RuntimeException e) {
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + port);
    return;
  }
  byte[] datagramBytes=new byte[BUFFER_SIZE];
  DatagramPacket datagram=new DatagramPacket(datagramBytes,BUFFER_SIZE);
  QueryKey.SecretKey key=QueryKey.generateSecretKey();
  QueryKey.SecretPad pad=QueryKey.generateSecretPad();
  while (shouldRun()) {
    try {
      socket.receive(datagram);
      byte[] data=datagram.getData();
      int length=datagram.getLength();
      try {
        InputStream in=new ByteArrayInputStream(data);
        Message message=Message.read(in);
        if (message == null)         continue;
        if (message instanceof PingRequest) {
          PingRequest pr=(PingRequest)message;
          pr.hop();
          if (pr.isQueryKeyRequest()) {
            QueryKey qk=QueryKey.getQueryKey(datagram.getAddress(),datagram.getPort(),key,pad);
            PingReply pRep=PingReply.createQueryKeyReply(pr.getGUID(),(byte)1,port,localhost,2,2,true,qk);
            pRep.hop();
            LOG.debug("String_Node_Str");
            QueryUnicaster.instance().handleQueryKeyPong(pRep);
          }
        }
synchronized (_messages) {
          if (LOG.isDebugEnabled())           LOG.debug("String_Node_Str" + (_messages.size() + 1) + "String_Node_Str"+ message);
          _messages.add(message);
          _messages.notify();
        }
      }
 catch (      BadPacketException e) {
        continue;
      }
    }
 catch (    InterruptedIOException e) {
      continue;
    }
catch (    IOException e) {
      continue;
    }
  }
  if (LOG.isDebugEnabled())   LOG.debug("String_Node_Str" + port);
  socket.close();
}