Program: 103539
Project: 103539
Buggy source:
/** 
 * Returns a Contact header containing a sip URI based on a localhost address and therefore usable in REGISTER requests only.
 * @param intendedDestination the destination that we plan to be sendingthis contact header to.
 * @return a Contact header based upon a local inet address.
 */
public ContactHeader getContactHeader(SipURI intendedDestination){
  ContactHeader registrationContactHeader=null;
  ListeningPoint srcListeningPoint=getListeningPoint(intendedDestination);
  InetAddress targetAddress=getIntendedDestination(intendedDestination);
  try {
    InetAddress localAddress=SipActivator.getNetworkAddressManagerService().getLocalHost(targetAddress);
    SipURI contactURI=addressFactory.createSipURI(getAccountID().getUserID(),localAddress.getHostAddress());
    String transport=srcListeningPoint.getTransport();
    contactURI.setTransportParam(transport);
    int localPort=srcListeningPoint.getPort();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
      InetAddress intendedDestinationAddress=NetworkUtils.getInetAddress(intendedDestination.getHost());
      int dstPort=intendedDestination.getPort();
      if (!targetAddress.equals(intendedDestinationAddress) && getOutboundProxy() != null)       dstPort=getOutboundProxy().getPort();
      if (dstPort == -1)       dstPort=5060;
      InetSocketAddress localSockAddr=sipStackSharing.obtainLocalAddress(targetAddress,dstPort,localAddress);
      localPort=localSockAddr.getPort();
    }
    contactURI.setPort(localPort);
    String paramValue=getContactAddressCustomParamValue();
    if (paramValue != null) {
      contactURI.setParameter(SipStackSharing.CONTACT_ADDRESS_CUSTOM_PARAM_NAME,paramValue);
    }
    Address contactAddress=addressFactory.createAddress(contactURI);
    String ourDisplayName=getOurDisplayName();
    if (ourDisplayName != null) {
      contactAddress.setDisplayName(ourDisplayName);
    }
    registrationContactHeader=headerFactory.createContactHeader(contactAddress);
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + registrationContactHeader);
  }
 catch (  ParseException ex) {
    logger.error("String_Node_Str",ex);
    throw new IllegalArgumentException("String_Node_Str",ex);
  }
catch (  java.io.IOException ex) {
    logger.error("String_Node_Str",ex);
    throw new IllegalArgumentException("String_Node_Str",ex);
  }
  return registrationContactHeader;
}

Fixed version (ground truth):
/** 
 * Returns a Contact header containing a sip URI based on a localhost address and therefore usable in REGISTER requests only.
 * @param intendedDestination the destination that we plan to be sendingthis contact header to.
 * @return a Contact header based upon a local inet address.
 */
public ContactHeader getContactHeader(SipURI intendedDestination){
  ContactHeader registrationContactHeader=null;
  ListeningPoint srcListeningPoint=getListeningPoint(intendedDestination);
  InetSocketAddress targetAddress=getIntendedDestination(intendedDestination);
  try {
    InetAddress localAddress=SipActivator.getNetworkAddressManagerService().getLocalHost(targetAddress.getAddress());
    SipURI contactURI=addressFactory.createSipURI(getAccountID().getUserID(),localAddress.getHostAddress());
    String transport=srcListeningPoint.getTransport();
    contactURI.setTransportParam(transport);
    int localPort=srcListeningPoint.getPort();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
      InetSocketAddress localSockAddr=sipStackSharing.obtainLocalAddress(targetAddress.getAddress(),targetAddress.getPort(),localAddress);
      localPort=localSockAddr.getPort();
    }
    contactURI.setPort(localPort);
    String paramValue=getContactAddressCustomParamValue();
    if (paramValue != null) {
      contactURI.setParameter(SipStackSharing.CONTACT_ADDRESS_CUSTOM_PARAM_NAME,paramValue);
    }
    Address contactAddress=addressFactory.createAddress(contactURI);
    String ourDisplayName=getOurDisplayName();
    if (ourDisplayName != null) {
      contactAddress.setDisplayName(ourDisplayName);
    }
    registrationContactHeader=headerFactory.createContactHeader(contactAddress);
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + registrationContactHeader);
  }
 catch (  ParseException ex) {
    logger.error("String_Node_Str",ex);
    throw new IllegalArgumentException("String_Node_Str",ex);
  }
catch (  java.io.IOException ex) {
    logger.error("String_Node_Str",ex);
    throw new IllegalArgumentException("String_Node_Str",ex);
  }
  return registrationContactHeader;
}