Program: 29221
Project: 29221
Buggy source:
private List<String> getHostAndPort(HttpRequest request) throws IOException {
  boolean isWebServerRequest=false;
  Enumeration headerNames=((HttpServletRequest)request.getRequest()).getHeaderNames();
  String[] hostPort=null;
  boolean isHeaderPresent=false;
  while (headerNames.hasMoreElements()) {
    String headerName=(String)headerNames.nextElement();
    String hostVal;
    if (headerName.equalsIgnoreCase("String_Node_Str")) {
      hostVal=((HttpServletRequest)request.getRequest()).getHeader(headerName);
      isHeaderPresent=true;
      hostPort=hostVal.split("String_Node_Str");
    }
  }
  if (hostPort == null) {
    throw new ProtocolException(rb.getString("String_Node_Str"));
  }
  boolean isHostPortNullOrEmpty=((hostPort.length <= 1) || (hostPort[1] == null || hostPort[1].trim().isEmpty()));
  if (!isHeaderPresent) {
    isWebServerRequest=false;
  }
 else   if (isHostPortNullOrEmpty) {
    isWebServerRequest=true;
  }
 else {
    boolean breakFromLoop=false;
    for (    NetworkListener nwListener : nwListeners.getNetworkListener()) {
      String nwAddress=nwListener.getAddress();
      InetAddress[] localHostAdresses=new InetAddress[10];
      if (nwAddress == null || nwAddress.equals("String_Node_Str")) {
        nwAddress=NetUtils.getCanonicalHostName();
        if (!nwAddress.equals(hostPort[0])) {
          localHostAdresses=NetUtils.getHostAddresses();
          InetAddress hostAddress=InetAddress.getByName(hostPort[0]);
          for (          InetAddress inetAdress : localHostAdresses) {
            if (inetAdress.equals(hostAddress)) {
              String nwPort=nwListener.getPort();
              if (!nwPort.equals(hostPort[1])) {
                isWebServerRequest=true;
              }
 else {
                isWebServerRequest=false;
                breakFromLoop=true;
                break;
              }
            }
          }
        }
 else {
          String nwPort=nwListener.getPort();
          if (!nwPort.equals(hostPort[1])) {
            isWebServerRequest=true;
          }
 else {
            isWebServerRequest=false;
            breakFromLoop=true;
          }
        }
      }
      if (breakFromLoop && !isWebServerRequest) {
        break;
      }
    }
  }
  String serverHost=request.getRequest().getServerName();
  int redirectPort=request.getConnector().getRedirectPort();
  if (isWebServerRequest) {
    serverHost=hostPort[0];
    if (isHostPortNullOrEmpty) {
      redirectPort=-1;
    }
 else {
      redirectPort=Integer.parseInt(hostPort[1]);
    }
  }
  List<String> hostAndPort=new ArrayList<String>();
  hostAndPort.add(serverHost);
  hostAndPort.add(String.valueOf(redirectPort));
  return hostAndPort;
}

Fixed version (ground truth):
private List<String> getHostAndPort(HttpRequest request) throws IOException {
  boolean isWebServerRequest=false;
  Enumeration headerNames=((HttpServletRequest)request.getRequest()).getHeaderNames();
  String[] hostPort=null;
  boolean isHeaderPresent=false;
  while (headerNames.hasMoreElements()) {
    String headerName=(String)headerNames.nextElement();
    String hostVal;
    if (headerName.equalsIgnoreCase("String_Node_Str")) {
      hostVal=((HttpServletRequest)request.getRequest()).getHeader(headerName);
      isHeaderPresent=true;
      hostPort=hostVal.split("String_Node_Str");
    }
  }
  if (hostPort == null) {
    throw new ProtocolException(rb.getString("String_Node_Str"));
  }
  boolean isHostPortNullOrEmpty=((hostPort.length <= 1) || (hostPort[1] == null || hostPort[1].trim().isEmpty()));
  if (!isHeaderPresent) {
    isWebServerRequest=false;
  }
 else   if (isHostPortNullOrEmpty) {
    isWebServerRequest=true;
  }
 else {
    boolean breakFromLoop=false;
    for (    NetworkListener nwListener : nwListeners.getNetworkListener()) {
      String nwAddress=nwListener.getAddress();
      InetAddress[] localHostAdresses;
      if (nwAddress == null || nwAddress.equals("String_Node_Str")) {
        nwAddress=NetUtils.getCanonicalHostName();
        if (!nwAddress.equals(hostPort[0])) {
          localHostAdresses=NetUtils.getHostAddresses();
          InetAddress hostAddress=InetAddress.getByName(hostPort[0]);
          for (          InetAddress inetAdress : localHostAdresses) {
            if (inetAdress.equals(hostAddress)) {
              String nwPort=nwListener.getPort();
              if (!nwPort.equals(hostPort[1])) {
                isWebServerRequest=true;
              }
 else {
                isWebServerRequest=false;
                breakFromLoop=true;
                break;
              }
            }
          }
        }
 else {
          String nwPort=nwListener.getPort();
          if (!nwPort.equals(hostPort[1])) {
            isWebServerRequest=true;
          }
 else {
            isWebServerRequest=false;
            breakFromLoop=true;
          }
        }
      }
      if (breakFromLoop && !isWebServerRequest) {
        break;
      }
    }
  }
  String serverHost=request.getRequest().getServerName();
  int redirectPort=request.getConnector().getRedirectPort();
  if (isWebServerRequest) {
    serverHost=hostPort[0];
    if (isHostPortNullOrEmpty) {
      redirectPort=-1;
    }
 else {
      redirectPort=Integer.parseInt(hostPort[1]);
    }
  }
  List<String> hostAndPort=new ArrayList<String>();
  hostAndPort.add(serverHost);
  hostAndPort.add(String.valueOf(redirectPort));
  return hostAndPort;
}