Program: 103542
Project: 103542
Buggy source:
/** 
 * Initializes and returns an ArrayList with a single ViaHeader containing a localhost address usable with the specified s<tt>destination</tt>. This ArrayList may be used when sending requests to that destination. <p>
 * @param intendedDestination The address of the destination that therequest using the via headers will be sent to.
 * @return ViaHeader-s list to be used when sending requests.
 * @throws OperationFailedException code INTERNAL_ERROR if a ParseExceptionoccurs while initializing the array list.
 */
public ArrayList<ViaHeader> getLocalViaHeaders(SipURI intendedDestination) throws OperationFailedException {
  ArrayList<ViaHeader> viaHeaders=new ArrayList<ViaHeader>();
  ListeningPoint srcListeningPoint=getListeningPoint(intendedDestination.getTransportParam());
  try {
    InetAddress localAddress=SipActivator.getNetworkAddressManagerService().getLocalHost(getIntendedDestination(intendedDestination));
    int localPort=srcListeningPoint.getPort();
    String transport=srcListeningPoint.getTransport();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
      int dstPort=intendedDestination.getPort();
      if (dstPort == -1)       dstPort=5060;
      InetSocketAddress localSockAddr=sipStackSharing.obtainLocalAddress(NetworkUtils.getInetAddress(intendedDestination.getHost()),dstPort,localAddress);
      localPort=localSockAddr.getPort();
    }
    ViaHeader viaHeader=headerFactory.createViaHeader(localAddress.getHostAddress(),localPort,transport,null);
    viaHeaders.add(viaHeader);
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + viaHeader);
    return viaHeaders;
  }
 catch (  ParseException ex) {
    logger.error("String_Node_Str",ex);
    throw new OperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,ex);
  }
catch (  InvalidArgumentException ex) {
    logger.error("String_Node_Str" + sipStackSharing.getLP(ListeningPoint.UDP).getPort(),ex);
    throw new OperationFailedException("String_Node_Str" + sipStackSharing.getLP(ListeningPoint.UDP).getPort(),OperationFailedException.INTERNAL_ERROR,ex);
  }
catch (  java.io.IOException ex) {
    logger.error("String_Node_Str" + sipStackSharing.getLP(ListeningPoint.UDP).getPort(),ex);
    throw new OperationFailedException("String_Node_Str" + sipStackSharing.getLP(ListeningPoint.UDP).getPort(),OperationFailedException.INTERNAL_ERROR,ex);
  }
}

Fixed version (ground truth):
/** 
 * Initializes and returns an ArrayList with a single ViaHeader containing a localhost address usable with the specified s<tt>destination</tt>. This ArrayList may be used when sending requests to that destination. <p>
 * @param intendedDestination The address of the destination that therequest using the via headers will be sent to.
 * @return ViaHeader-s list to be used when sending requests.
 * @throws OperationFailedException code INTERNAL_ERROR if a ParseExceptionoccurs while initializing the array list.
 */
public ArrayList<ViaHeader> getLocalViaHeaders(SipURI intendedDestination) throws OperationFailedException {
  ArrayList<ViaHeader> viaHeaders=new ArrayList<ViaHeader>();
  ListeningPoint srcListeningPoint=getListeningPoint(intendedDestination.getTransportParam());
  try {
    InetSocketAddress targetAddress=getIntendedDestination(intendedDestination);
    InetAddress localAddress=SipActivator.getNetworkAddressManagerService().getLocalHost(targetAddress.getAddress());
    int localPort=srcListeningPoint.getPort();
    String transport=srcListeningPoint.getTransport();
    if (ListeningPoint.TCP.equalsIgnoreCase(transport)) {
      InetSocketAddress localSockAddr=sipStackSharing.obtainLocalAddress(targetAddress.getAddress(),targetAddress.getPort(),localAddress);
      localPort=localSockAddr.getPort();
    }
    ViaHeader viaHeader=headerFactory.createViaHeader(localAddress.getHostAddress(),localPort,transport,null);
    viaHeaders.add(viaHeader);
    if (logger.isDebugEnabled())     logger.debug("String_Node_Str" + viaHeader);
    return viaHeaders;
  }
 catch (  ParseException ex) {
    logger.error("String_Node_Str",ex);
    throw new OperationFailedException("String_Node_Str",OperationFailedException.INTERNAL_ERROR,ex);
  }
catch (  InvalidArgumentException ex) {
    logger.error("String_Node_Str" + sipStackSharing.getLP(ListeningPoint.UDP).getPort(),ex);
    throw new OperationFailedException("String_Node_Str" + sipStackSharing.getLP(ListeningPoint.UDP).getPort(),OperationFailedException.INTERNAL_ERROR,ex);
  }
catch (  java.io.IOException ex) {
    logger.error("String_Node_Str" + sipStackSharing.getLP(ListeningPoint.UDP).getPort(),ex);
    throw new OperationFailedException("String_Node_Str" + sipStackSharing.getLP(ListeningPoint.UDP).getPort(),OperationFailedException.NETWORK_FAILURE,ex);
  }
}