Program: 103352
Project: 103352
Buggy source:
/** 
 * Extracts all properties concerning the usage of an outbound proxy for this account.
 * @param accountID the account whose outbound proxy we are currentlyinitializing.
 * @param ix index of the address to use.
 */
void initOutboundProxy(SipAccountID accountID,int ix){
  String proxyAddressStr=accountID.getAccountPropertyString(ProtocolProviderFactory.PROXY_ADDRESS);
  boolean proxyAddressAndPortEntered=false;
  if (proxyAddressStr == null || proxyAddressStr.trim().length() == 0 || accountID.getAccountPropertyBoolean(ProtocolProviderFactory.PROXY_AUTO_CONFIG,false)) {
    String userID=accountID.getAccountPropertyString(ProtocolProviderFactory.USER_ID);
    int domainIx=userID.indexOf("String_Node_Str");
    if (domainIx > 0) {
      proxyAddressStr=userID.substring(domainIx + 1);
    }
 else {
      proxyAddressStr=accountID.getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS);
      if (proxyAddressStr == null || proxyAddressStr.trim().length() == 0) {
        return;
      }
    }
  }
 else {
    if (accountID.getAccountProperty(ProtocolProviderFactory.PROXY_PORT) != null) {
      proxyAddressAndPortEntered=true;
    }
  }
  InetAddress proxyAddress=null;
  int proxyPort=ListeningPoint.PORT_5060;
  String proxyTransport=accountID.getAccountPropertyString(ProtocolProviderFactory.PREFERRED_TRANSPORT);
  if (proxyTransport != null && proxyTransport.length() > 0) {
    if (!proxyTransport.equals(ListeningPoint.UDP) && !proxyTransport.equals(ListeningPoint.TCP) && !proxyTransport.equals(ListeningPoint.TLS)) {
      throw new IllegalArgumentException(proxyTransport + "String_Node_Str" + "String_Node_Str");
    }
  }
 else {
    proxyTransport=getDefaultTransport();
  }
  try {
    proxyPort=accountID.getAccountPropertyInt(ProtocolProviderFactory.PROXY_PORT,proxyPort);
    if (proxyPort > NetworkUtils.MAX_PORT_NUMBER) {
      throw new IllegalArgumentException(proxyPort + "String_Node_Str" + NetworkUtils.MAX_PORT_NUMBER+ "String_Node_Str");
    }
    InetSocketAddress proxySocketAddress=null;
    if (accountID.getAccountPropertyBoolean(ProtocolProviderFactory.PROXY_AUTO_CONFIG,false)) {
      if (connectionAddresses == null) {
        ArrayList<InetSocketAddress> proxySocketAddressesList=new ArrayList<InetSocketAddress>();
        ArrayList<String> proxyTransportsList=new ArrayList<String>();
        resolveSipAddress(proxyAddressStr,proxyTransport,proxySocketAddressesList,proxyTransportsList,true);
        connectionTransports=proxyTransportsList.toArray(new String[proxyTransportsList.size()]);
        connectionAddresses=proxySocketAddressesList.toArray(new InetSocketAddress[proxySocketAddressesList.size()]);
      }
      proxyTransport=connectionTransports[ix];
      proxySocketAddress=connectionAddresses[ix];
    }
 else {
      if (proxyAddressAndPortEntered) {
        if (connectionAddresses == null) {
          ArrayList<InetSocketAddress> addresses=new ArrayList<InetSocketAddress>();
          resolveAddresses(proxyAddressStr,addresses,checkPreferIPv6Addresses(),proxyPort);
          connectionAddresses=addresses.toArray(new InetSocketAddress[addresses.size()]);
          connectionTransports=new String[addresses.size()];
          Arrays.fill(connectionTransports,proxyTransport);
        }
        if (connectionAddresses.length > ix)         proxySocketAddress=connectionAddresses[ix];
      }
 else {
        if (connectionAddresses == null) {
          ArrayList<InetSocketAddress> proxySocketAddressesList=new ArrayList<InetSocketAddress>();
          ArrayList<String> proxyTransportsList=new ArrayList<String>();
          resolveSipAddress(proxyAddressStr,proxyTransport,proxySocketAddressesList,proxyTransportsList,false);
          connectionTransports=proxyTransportsList.toArray(new String[proxyTransportsList.size()]);
          connectionAddresses=proxySocketAddressesList.toArray(new InetSocketAddress[proxySocketAddressesList.size()]);
        }
        proxyTransport=connectionTransports[ix];
        proxySocketAddress=connectionAddresses[ix];
      }
    }
    if (proxySocketAddress == null)     throw new UnknownHostException();
    proxyAddress=proxySocketAddress.getAddress();
    proxyPort=proxySocketAddress.getPort();
    if (logger.isTraceEnabled())     logger.trace("String_Node_Str" + proxyAddressStr);
    accountID.putAccountProperty(ProtocolProviderFactory.PROXY_ADDRESS_VALIDATED,Boolean.toString(true));
  }
 catch (  UnknownHostException ex) {
    logger.error(proxyAddressStr + "String_Node_Str" + "String_Node_Str",ex);
    boolean isProxyValidated=accountID.getAccountPropertyBoolean(ProtocolProviderFactory.PROXY_ADDRESS_VALIDATED,false);
    if (!isProxyValidated) {
      throw new IllegalArgumentException(proxyAddressStr + "String_Node_Str" + "String_Node_Str",ex);
    }
  }
  if (connectionAddresses == null || connectionAddresses.length == 0) {
    sipRegistrarConnection=null;
    connectionAddresses=null;
    connectionTransports=null;
    fireRegistrationStateChanged(RegistrationState.UNREGISTERED,RegistrationState.CONNECTION_FAILED,RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND,"String_Node_Str");
    return;
  }
  if (proxyAddress == null) {
    return;
  }
  try {
    if (this.getRegistrarConnection() != null)     this.getRegistrarConnection().setTransport(proxyTransport);
  }
 catch (  ParseException ex) {
    logger.error("String_Node_Str" + currentConnectionAddress,ex);
    throw new IllegalArgumentException("String_Node_Str" + currentConnectionAddress + "String_Node_Str"+ ex.getMessage());
  }
  StringBuilder proxyStringBuffer=new StringBuilder(proxyAddress.getHostAddress());
  if (proxyAddress instanceof Inet6Address) {
    proxyStringBuffer.insert(0,'[');
    proxyStringBuffer.append(']');
  }
  proxyStringBuffer.append(':');
  proxyStringBuffer.append(Integer.toString(proxyPort));
  proxyStringBuffer.append('/');
  proxyStringBuffer.append(proxyTransport);
  this.outboundProxyString=proxyStringBuffer.toString();
  this.outboundProxySocketAddress=new InetSocketAddress(proxyAddress,proxyPort);
  this.outboundProxyTransport=proxyTransport;
}

Fixed version (ground truth):
/** 
 * Extracts all properties concerning the usage of an outbound proxy for this account.
 * @param accountID the account whose outbound proxy we are currentlyinitializing.
 * @param ix index of the address to use.
 */
void initOutboundProxy(SipAccountID accountID,int ix){
  String proxyAddressStr=accountID.getAccountPropertyString(ProtocolProviderFactory.PROXY_ADDRESS);
  boolean proxyAddressAndPortEntered=false;
  if (proxyAddressStr == null || proxyAddressStr.trim().length() == 0 || accountID.getAccountPropertyBoolean(ProtocolProviderFactory.PROXY_AUTO_CONFIG,false)) {
    String userID=accountID.getAccountPropertyString(ProtocolProviderFactory.USER_ID);
    int domainIx=userID.indexOf("String_Node_Str");
    if (domainIx > 0) {
      proxyAddressStr=userID.substring(domainIx + 1);
    }
 else {
      proxyAddressStr=accountID.getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS);
      if (proxyAddressStr == null || proxyAddressStr.trim().length() == 0) {
        return;
      }
    }
  }
 else {
    if (accountID.getAccountProperty(ProtocolProviderFactory.PROXY_PORT) != null) {
      proxyAddressAndPortEntered=true;
    }
  }
  InetAddress proxyAddress=null;
  int proxyPort=ListeningPoint.PORT_5060;
  String proxyTransport=accountID.getAccountPropertyString(ProtocolProviderFactory.PREFERRED_TRANSPORT);
  if (proxyTransport != null && proxyTransport.length() > 0) {
    if (!proxyTransport.equals(ListeningPoint.UDP) && !proxyTransport.equals(ListeningPoint.TCP) && !proxyTransport.equals(ListeningPoint.TLS)) {
      throw new IllegalArgumentException(proxyTransport + "String_Node_Str" + "String_Node_Str");
    }
  }
 else {
    proxyTransport=getDefaultTransport();
  }
  try {
    proxyPort=accountID.getAccountPropertyInt(ProtocolProviderFactory.PROXY_PORT,proxyPort);
    if (proxyPort > NetworkUtils.MAX_PORT_NUMBER) {
      throw new IllegalArgumentException(proxyPort + "String_Node_Str" + NetworkUtils.MAX_PORT_NUMBER+ "String_Node_Str");
    }
    InetSocketAddress proxySocketAddress=null;
    if (accountID.getAccountPropertyBoolean(ProtocolProviderFactory.PROXY_AUTO_CONFIG,false)) {
      if (connectionAddresses == null) {
        ArrayList<InetSocketAddress> proxySocketAddressesList=new ArrayList<InetSocketAddress>();
        ArrayList<String> proxyTransportsList=new ArrayList<String>();
        resolveSipAddress(proxyAddressStr,proxyTransport,proxySocketAddressesList,proxyTransportsList,true);
        connectionTransports=proxyTransportsList.toArray(new String[proxyTransportsList.size()]);
        connectionAddresses=proxySocketAddressesList.toArray(new InetSocketAddress[proxySocketAddressesList.size()]);
      }
      proxyTransport=connectionTransports[ix];
      proxySocketAddress=connectionAddresses[ix];
    }
 else {
      if (proxyAddressAndPortEntered) {
        if (connectionAddresses == null) {
          ArrayList<InetSocketAddress> addresses=new ArrayList<InetSocketAddress>();
          resolveAddresses(proxyAddressStr,addresses,checkPreferIPv6Addresses(),proxyPort);
          connectionAddresses=addresses.toArray(new InetSocketAddress[addresses.size()]);
          connectionTransports=new String[addresses.size()];
          Arrays.fill(connectionTransports,proxyTransport);
        }
        if (connectionAddresses.length > ix)         proxySocketAddress=connectionAddresses[ix];
      }
 else {
        if (connectionAddresses == null) {
          ArrayList<InetSocketAddress> proxySocketAddressesList=new ArrayList<InetSocketAddress>();
          ArrayList<String> proxyTransportsList=new ArrayList<String>();
          resolveSipAddress(proxyAddressStr,proxyTransport,proxySocketAddressesList,proxyTransportsList,false);
          connectionTransports=proxyTransportsList.toArray(new String[proxyTransportsList.size()]);
          connectionAddresses=proxySocketAddressesList.toArray(new InetSocketAddress[proxySocketAddressesList.size()]);
        }
        proxyTransport=connectionTransports[ix];
        proxySocketAddress=connectionAddresses[ix];
      }
    }
    if (proxySocketAddress == null)     throw new UnknownHostException();
    proxyAddress=proxySocketAddress.getAddress();
    if (this.currentConnectionAddress == null)     this.currentConnectionAddress=proxySocketAddress;
    proxyPort=proxySocketAddress.getPort();
    if (logger.isTraceEnabled())     logger.trace("String_Node_Str" + proxyAddressStr);
    accountID.putAccountProperty(ProtocolProviderFactory.PROXY_ADDRESS_VALIDATED,Boolean.toString(true));
  }
 catch (  UnknownHostException ex) {
    logger.error(proxyAddressStr + "String_Node_Str" + "String_Node_Str",ex);
    boolean isProxyValidated=accountID.getAccountPropertyBoolean(ProtocolProviderFactory.PROXY_ADDRESS_VALIDATED,false);
    if (!isProxyValidated) {
      throw new IllegalArgumentException(proxyAddressStr + "String_Node_Str" + "String_Node_Str",ex);
    }
  }
  if (connectionAddresses == null || connectionAddresses.length == 0) {
    sipRegistrarConnection=null;
    connectionAddresses=null;
    connectionTransports=null;
    fireRegistrationStateChanged(RegistrationState.UNREGISTERED,RegistrationState.CONNECTION_FAILED,RegistrationStateChangeEvent.REASON_SERVER_NOT_FOUND,"String_Node_Str");
    return;
  }
  if (proxyAddress == null) {
    return;
  }
  try {
    if (this.getRegistrarConnection() != null)     this.getRegistrarConnection().setTransport(proxyTransport);
  }
 catch (  ParseException ex) {
    logger.error("String_Node_Str" + currentConnectionAddress,ex);
    throw new IllegalArgumentException("String_Node_Str" + currentConnectionAddress + "String_Node_Str"+ ex.getMessage());
  }
  StringBuilder proxyStringBuffer=new StringBuilder(proxyAddress.getHostAddress());
  if (proxyAddress instanceof Inet6Address) {
    proxyStringBuffer.insert(0,'[');
    proxyStringBuffer.append(']');
  }
  proxyStringBuffer.append(':');
  proxyStringBuffer.append(Integer.toString(proxyPort));
  proxyStringBuffer.append('/');
  proxyStringBuffer.append(proxyTransport);
  this.outboundProxyString=proxyStringBuffer.toString();
  this.outboundProxySocketAddress=new InetSocketAddress(proxyAddress,proxyPort);
  this.outboundProxyTransport=proxyTransport;
}