Program: 62626
Project: 62626
Buggy source:
private void receiveDiscoveryMessage(){
  DatagramSocket bcReceipt=null;
  try {
    discoveryRunning=true;
    bcReceipt=new DatagramSocket(23272);
    bcReceipt.setReuseAddress(true);
    bcReceipt.setSoTimeout(5000);
    while (discoveryRunning) {
      byte[] recvBuf=new byte[1500];
      DatagramPacket receivePacket=new DatagramPacket(recvBuf,recvBuf.length);
      bcReceipt.receive(receivePacket);
      String message=new String(receivePacket.getData(),receivePacket.getOffset(),receivePacket.getLength());
      logger.trace("String_Node_Str",receivePacket.getAddress(),message.length(),message);
      if (message.startsWith("String_Node_Str") && !message.equals(MAXCUBE_DISCOVER_STRING)) {
        String maxCubeIP=receivePacket.getAddress().getHostAddress();
        String maxCubeState=message.substring(0,8);
        String serialNumber=message.substring(8,18);
        String msgValidid=message.substring(18,19);
        String requestType=message.substring(19,20);
        String rfAddress="String_Node_Str";
        logger.debug("String_Node_Str");
        logger.debug("String_Node_Str",maxCubeIP);
        logger.debug("String_Node_Str",maxCubeState);
        logger.debug("String_Node_Str",serialNumber);
        logger.trace("String_Node_Str",msgValidid);
        logger.trace("String_Node_Str",requestType);
        if (requestType.equals("String_Node_Str")) {
          rfAddress=Utils.getHex(message.substring(21,24).getBytes()).replace("String_Node_Str","String_Node_Str").toLowerCase();
          String firmwareVersion=Utils.getHex(message.substring(24,26).getBytes()).replace("String_Node_Str","String_Node_Str");
          logger.debug("String_Node_Str",rfAddress);
          logger.debug("String_Node_Str",firmwareVersion);
        }
        discoveryResultSubmission(maxCubeIP,serialNumber,rfAddress);
      }
    }
  }
 catch (  SocketTimeoutException e) {
    logger.trace("String_Node_Str");
    discoveryRunning=false;
  }
catch (  IOException e) {
    logger.debug("String_Node_Str",e.getMessage());
    discoveryRunning=false;
  }
 finally {
    try {
      if (bcReceipt != null)       bcReceipt.close();
    }
 catch (    Exception e) {
      logger.debug(e.toString());
    }
  }
}

Fixed version (ground truth):
private void receiveDiscoveryMessage(){
  DatagramSocket bcReceipt=null;
  try {
    discoveryRunning=true;
    bcReceipt=new DatagramSocket(23272);
    bcReceipt.setReuseAddress(true);
    bcReceipt.setSoTimeout(5000);
    while (discoveryRunning) {
      byte[] recvBuf=new byte[1500];
      DatagramPacket receivePacket=new DatagramPacket(recvBuf,recvBuf.length);
      bcReceipt.receive(receivePacket);
      byte[] messageBuf=Arrays.copyOfRange(receivePacket.getData(),receivePacket.getOffset(),receivePacket.getOffset() + receivePacket.getLength());
      String message=new String(messageBuf);
      logger.trace("String_Node_Str",receivePacket.getAddress(),message.length(),message);
      if (message.startsWith("String_Node_Str") && !message.equals(MAXCUBE_DISCOVER_STRING)) {
        String maxCubeIP=receivePacket.getAddress().getHostAddress();
        String maxCubeState=message.substring(0,8);
        String serialNumber=message.substring(8,18);
        String msgValidid=message.substring(18,19);
        String requestType=message.substring(19,20);
        String rfAddress="String_Node_Str";
        logger.debug("String_Node_Str");
        logger.debug("String_Node_Str",maxCubeIP);
        logger.trace("String_Node_Str",maxCubeState);
        logger.debug("String_Node_Str",serialNumber);
        logger.trace("String_Node_Str",msgValidid);
        logger.trace("String_Node_Str",requestType);
        if (requestType.equals("String_Node_Str")) {
          rfAddress=Utils.getHex(Arrays.copyOfRange(messageBuf,21,24)).replace("String_Node_Str","String_Node_Str").toLowerCase();
          String firmwareVersion=Utils.getHex(Arrays.copyOfRange(messageBuf,24,26)).replace("String_Node_Str","String_Node_Str");
          logger.debug("String_Node_Str",rfAddress);
          logger.debug("String_Node_Str",firmwareVersion);
        }
        discoveryResultSubmission(maxCubeIP,serialNumber,rfAddress);
      }
    }
  }
 catch (  SocketTimeoutException e) {
    logger.trace("String_Node_Str");
    discoveryRunning=false;
  }
catch (  IOException e) {
    logger.debug("String_Node_Str",e.getMessage());
    discoveryRunning=false;
  }
 finally {
    try {
      if (bcReceipt != null) {
        bcReceipt.close();
      }
    }
 catch (    Exception e) {
      logger.debug(e.toString());
    }
  }
}