Program: 104035
Project: 104035
Buggy source:
/** 
 * The diagnostics code itself.
 */
public void run(){
  logger.debug("String_Node_Str" + addressEntry);
  setDiagnosticsStatus(this.DIAGNOSTICS_STATUS_DISOVERING_CONFIG);
  InetAddress address=addressEntry.getInetAddress();
  if (addressEntry.isIPv6()) {
    if (addressEntry.isLinkLocal()) {
      addressEntry.setAddressPreference(ADDR_PREF_LOCAL_IPV6);
      setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
      return;
    }
    if (addressEntry.is6to4()) {
      addressEntry.setAddressPreference(AddressPreference.MIN);
      setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
      return;
    }
    addressEntry.setAddressPreference(ADDR_PREF_GLOBAL_IPV6);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_COMPLETED);
    return;
  }
  if (addressEntry.isIPv4LinkLocalAutoconf()) {
    addressEntry.setAddressPreference(AddressPreference.MIN);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    return;
  }
  if (addressEntry.isLinkLocalIPv4Address()) {
    addressEntry.setAddressPreference(ADDR_PREF_PRIVATE_IPV4);
  }
 else {
    addressEntry.setAddressPreference(ADDR_PREF_GLOBAL_IPV4);
  }
  if (!useStun) {
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    return;
  }
  for (int i=0; i < bindRetries; i++) {
    StunAddress localStunAddress=new StunAddress(address,1024 + (int)(Math.random() * 64512));
    try {
      stunClient=new StunClient(localStunAddress);
      stunClient.start();
      logger.debug("String_Node_Str" + localStunAddress + "String_Node_Str");
      break;
    }
 catch (    StunException ex) {
      if (ex.getCause() instanceof SocketException && i < bindRetries) {
        logger.debug("String_Node_Str" + localStunAddress + "String_Node_Str");
        logger.debug("String_Node_Str",ex);
        continue;
      }
      logger.error("String_Node_Str" + addressEntry.toString() + "String_Node_Str"+ localStunAddress.getPort()+ "String_Node_Str",ex);
      setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
      return;
    }
  }
  StunMessageEvent event=null;
  try {
    event=stunClient.doStunTestI(primaryStunServerAddress);
  }
 catch (  StunException ex) {
    logger.error("String_Node_Str" + addressEntry.toString(),ex);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  if (event == null) {
    logger.debug("String_Node_Str" + addressEntry);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    logger.debug("String_Node_Str");
    return;
  }
  boolean isPublic;
  Message stunResponse=event.getMessage();
  Attribute mappedAttr=stunResponse.getAttribute(Attribute.MAPPED_ADDRESS);
  StunAddress mappedAddrFromTestI=((MappedAddressAttribute)mappedAttr).getAddress();
  Attribute changedAddressAttributeFromTestI=stunResponse.getAttribute(Attribute.CHANGED_ADDRESS);
  StunAddress secondaryStunServerAddress=((ChangedAddressAttribute)changedAddressAttributeFromTestI).getAddress();
  if (mappedAddrFromTestI == null) {
    logger.error("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    return;
  }
  if (mappedAddrFromTestI.equals(event.getSourceAccessPoint().getAddress())) {
    isPublic=true;
  }
 else {
    isPublic=false;
  }
  try {
    event=stunClient.doStunTestII(primaryStunServerAddress);
  }
 catch (  StunException ex) {
    logger.error("String_Node_Str" + addressEntry.toString(),ex);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    logger.debug("String_Node_Str");
    return;
  }
  if (event != null) {
    logger.error("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  try {
    event=stunClient.doStunTestI(secondaryStunServerAddress);
    logger.debug("String_Node_Str");
  }
 catch (  StunException ex) {
    logger.error("String_Node_Str" + addressEntry.toString(),ex);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  if (event == null) {
    logger.error("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  stunResponse=event.getMessage();
  mappedAttr=stunResponse.getAttribute(Attribute.MAPPED_ADDRESS);
  StunAddress mappedAddrFromSecServer=((MappedAddressAttribute)mappedAttr).getAddress();
  if (!mappedAddrFromTestI.equals(mappedAddrFromSecServer)) {
    logger.debug("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  try {
    event=stunClient.doStunTestIII(primaryStunServerAddress);
    logger.debug("String_Node_Str");
  }
 catch (  StunException ex) {
    logger.error("String_Node_Str" + addressEntry.toString(),ex);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  if (event == null) {
    logger.debug("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  logger.debug("String_Node_Str" + addressEntry.toString());
  setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
  stunClient.shutDown();
}

Fixed version (ground truth):
/** 
 * The diagnostics code itself.
 */
public void run(){
  logger.debug("String_Node_Str" + addressEntry);
  setDiagnosticsStatus(DIAGNOSTICS_STATUS_DISOVERING_CONFIG);
  InetAddress address=addressEntry.getInetAddress();
  if (addressEntry.isIPv6()) {
    if (addressEntry.isLinkLocal()) {
      addressEntry.setAddressPreference(ADDR_PREF_LOCAL_IPV6);
      setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
      return;
    }
    if (addressEntry.is6to4()) {
      addressEntry.setAddressPreference(AddressPreference.MIN);
      setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
      return;
    }
    addressEntry.setAddressPreference(ADDR_PREF_GLOBAL_IPV6);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_COMPLETED);
    return;
  }
  if (addressEntry.isIPv4LinkLocalAutoconf()) {
    addressEntry.setAddressPreference(AddressPreference.MIN);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    return;
  }
  if (addressEntry.isLinkLocalIPv4Address()) {
    addressEntry.setAddressPreference(ADDR_PREF_PRIVATE_IPV4);
  }
 else {
    addressEntry.setAddressPreference(ADDR_PREF_GLOBAL_IPV4);
  }
  if (!useStun) {
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    return;
  }
  for (int i=0; i < bindRetries; i++) {
    StunAddress localStunAddress=new StunAddress(address,1024 + (int)(Math.random() * 64512));
    try {
      stunClient=new StunClient(localStunAddress);
      stunClient.start();
      logger.debug("String_Node_Str" + localStunAddress + "String_Node_Str");
      break;
    }
 catch (    StunException ex) {
      if (ex.getCause() instanceof SocketException && i < bindRetries) {
        logger.debug("String_Node_Str" + localStunAddress + "String_Node_Str");
        logger.debug("String_Node_Str",ex);
        continue;
      }
      logger.error("String_Node_Str" + addressEntry.toString() + "String_Node_Str"+ localStunAddress.getPort()+ "String_Node_Str",ex);
      setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
      return;
    }
  }
  StunMessageEvent event=null;
  try {
    event=stunClient.doStunTestI(primaryStunServerAddress);
  }
 catch (  StunException ex) {
    logger.error("String_Node_Str" + addressEntry.toString(),ex);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  if (event == null) {
    logger.debug("String_Node_Str" + addressEntry);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    logger.debug("String_Node_Str");
    return;
  }
  boolean isPublic;
  Message stunResponse=event.getMessage();
  Attribute mappedAttr=stunResponse.getAttribute(Attribute.MAPPED_ADDRESS);
  StunAddress mappedAddrFromTestI=((MappedAddressAttribute)mappedAttr).getAddress();
  Attribute changedAddressAttributeFromTestI=stunResponse.getAttribute(Attribute.CHANGED_ADDRESS);
  StunAddress secondaryStunServerAddress=((ChangedAddressAttribute)changedAddressAttributeFromTestI).getAddress();
  if (mappedAddrFromTestI == null) {
    logger.error("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    return;
  }
  if (mappedAddrFromTestI.equals(event.getSourceAccessPoint().getAddress())) {
    isPublic=true;
  }
 else {
    isPublic=false;
  }
  try {
    event=stunClient.doStunTestII(primaryStunServerAddress);
  }
 catch (  StunException ex) {
    logger.error("String_Node_Str" + addressEntry.toString(),ex);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    logger.debug("String_Node_Str");
    return;
  }
  if (event != null) {
    logger.error("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  try {
    event=stunClient.doStunTestI(secondaryStunServerAddress);
    logger.debug("String_Node_Str");
  }
 catch (  StunException ex) {
    logger.error("String_Node_Str" + addressEntry.toString(),ex);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  if (event == null) {
    logger.error("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  stunResponse=event.getMessage();
  mappedAttr=stunResponse.getAttribute(Attribute.MAPPED_ADDRESS);
  StunAddress mappedAddrFromSecServer=((MappedAddressAttribute)mappedAttr).getAddress();
  if (!mappedAddrFromTestI.equals(mappedAddrFromSecServer)) {
    logger.debug("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  try {
    event=stunClient.doStunTestIII(primaryStunServerAddress);
    logger.debug("String_Node_Str");
  }
 catch (  StunException ex) {
    logger.error("String_Node_Str" + addressEntry.toString(),ex);
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  if (event == null) {
    logger.debug("String_Node_Str" + addressEntry.toString());
    setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
    stunClient.shutDown();
    return;
  }
  logger.debug("String_Node_Str" + addressEntry.toString());
  setDiagnosticsStatus(DIAGNOSTICS_STATUS_TERMINATED);
  stunClient.shutDown();
}