Program: 79628
Project: 79628
Buggy source:
/** 
 * Sends the request to the original Auth server and receives the result data.
 * @param request HttpServletRequest to be sent
 * @param response HttpServletResponse to be received
 * @param cookieURL URL of the original authentication server to beconnected
 * @return HashMap of the result data from the original server's response
 */
public static Map<String,Object> sendAuthRequestToOrigServer(HttpServletRequest request,HttpServletResponse response,String cookieURL){
  Map<String,Object> origRequestData=new HashMap<String,Object>();
  if (utilDebug.messageEnabled()) {
    StringBuilder message=new StringBuilder();
    Enumeration<String> requestHeaders=request.getHeaderNames();
    while (requestHeaders.hasMoreElements()) {
      String name=requestHeaders.nextElement();
      Enumeration value=(Enumeration)request.getHeaders(name);
      message.append("String_Node_Str").append(name).append("String_Node_Str").append(value).append("String_Node_Str");
    }
    utilDebug.message(message.toString());
  }
  HttpURLConnection conn=null;
  OutputStream out=null;
  String strCookies=null;
  URL authURL=null;
  try {
    String queryString=request.getQueryString();
    if (queryString != null) {
      authURL=new URL(cookieURL + "String_Node_Str" + queryString);
    }
 else {
      authURL=new URL(cookieURL);
    }
    if (utilDebug.messageEnabled()) {
      utilDebug.message("String_Node_Str" + authURL);
    }
    conn=HttpURLConnectionManager.getConnection(authURL);
    conn.setUseCaches(useCache);
    conn.setFollowRedirects(false);
    conn.setInstanceFollowRedirects(false);
    conn.setRequestProperty(ISAuthConstants.ACCEPT_LANG_HEADER,request.getHeader(ISAuthConstants.ACCEPT_LANG_HEADER));
    conn.setRequestProperty("String_Node_Str",request.getHeader("String_Node_Str"));
    List<Cookie> cookies=removeLocalLoadBalancingCookie(asList(request.getCookies()));
    strCookies=getCookiesString(cookies);
    if (strCookies != null) {
      if (utilDebug.messageEnabled()) {
        utilDebug.message("String_Node_Str" + strCookies);
      }
      conn.setRequestProperty("String_Node_Str",strCookies);
    }
    utilDebug.message("String_Node_Str");
    copyRequestHeaders(request,conn);
    if (request.getMethod().equals("String_Node_Str")) {
      conn.connect();
    }
 else {
      Map<String,Set<String>> queryParams=new HashMap<String,Set<String>>();
      if (queryString != null) {
        for (        String param : queryString.split("String_Node_Str")) {
          int idx=param.indexOf('=');
          if (idx != -1) {
            String paramName=param.substring(0,idx);
            String paramValue=param.substring(idx + 1);
            Set<String> values=queryParams.get(paramName);
            if (values == null) {
              values=new HashSet<String>();
              queryParams.put(paramName,values);
            }
            values.add(paramValue);
          }
        }
      }
      conn.setRequestProperty("String_Node_Str","String_Node_Str");
      Map<String,String[]> params=request.getParameterMap();
      Map<String,Set<String>> postParams=new HashMap<String,Set<String>>();
      for (      Map.Entry<String,String[]> entry : params.entrySet()) {
        if (queryParams.containsKey(entry.getKey())) {
        }
 else {
          postParams.put(entry.getKey(),new HashSet<String>(asList(entry.getValue())));
        }
      }
      String postData=getFormData(postParams);
      if (utilDebug.messageEnabled()) {
        utilDebug.message("String_Node_Str" + postData);
      }
      if (postData.trim().length() > 0) {
        conn.setDoOutput(true);
        conn.setRequestMethod("String_Node_Str");
        out=conn.getOutputStream();
        PrintWriter pw=new PrintWriter(out);
        pw.print(postData);
        pw.flush();
        pw.close();
      }
    }
    utilDebug.message("String_Node_Str");
    if (utilDebug.messageEnabled()) {
      utilDebug.message("String_Node_Str",conn.getResponseCode(),conn.getResponseMessage());
    }
    if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
      StringBuilder in_buf=new StringBuilder();
      BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream(),"String_Node_Str"));
      int len;
      char[] buf=new char[1024];
      while ((len=in.read(buf,0,buf.length)) != -1) {
        in_buf.append(buf,0,len);
      }
      String in_string=in_buf.toString();
      if (utilDebug.messageEnabled()) {
        utilDebug.message("String_Node_Str" + in_string);
      }
      origRequestData.put("String_Node_Str",in_string);
    }
 else {
      utilDebug.warning("String_Node_Str");
    }
    String client_type=conn.getHeaderField("String_Node_Str");
    if (client_type != null) {
      origRequestData.put("String_Node_Str",client_type);
    }
    String redirect_url=conn.getHeaderField("String_Node_Str");
    if (redirect_url != null) {
      try {
        URL gotoURL=new URL(redirect_url);
        if (isSameServer(authURL,gotoURL)) {
          if (utilDebug.messageEnabled()) {
            utilDebug.message("String_Node_Str");
          }
          String path=gotoURL.getPath();
          String query=gotoURL.getQuery();
          redirect_url=(path != null ? path : "String_Node_Str") + (query != null ? "String_Node_Str" + gotoURL.getQuery() : "String_Node_Str");
        }
        if (utilDebug.messageEnabled()) {
          utilDebug.message("String_Node_Str" + redirect_url);
        }
        origRequestData.put("String_Node_Str",redirect_url);
      }
 catch (      MalformedURLException murle) {
        origRequestData.put("String_Node_Str",redirect_url);
      }
    }
    String content_type=conn.getHeaderField("String_Node_Str");
    if (content_type != null) {
      origRequestData.put("String_Node_Str",content_type);
    }
    origRequestData.put("String_Node_Str",conn.getResponseCode());
    copyResponseHeaders(conn.getHeaderFields(),response);
  }
 catch (  IOException ioe) {
    origRequestData.put("String_Node_Str",ioe);
  }
catch (  Exception e) {
    if (utilDebug.warningEnabled()) {
      utilDebug.warning("String_Node_Str",e);
    }
  }
 finally {
    if (out != null) {
      try {
        out.close();
      }
 catch (      IOException ioe) {
        if (utilDebug.messageEnabled()) {
          utilDebug.message("String_Node_Str",ioe);
        }
      }
    }
  }
  return origRequestData;
}

Fixed version (ground truth):
/** 
 * Sends the request to the original Auth server and receives the result data.
 * @param request HttpServletRequest to be sent
 * @param response HttpServletResponse to be received
 * @param cookieURL URL of the original authentication server to beconnected
 * @return HashMap of the result data from the original server's response
 */
public static Map<String,Object> sendAuthRequestToOrigServer(HttpServletRequest request,HttpServletResponse response,String cookieURL){
  Map<String,Object> origRequestData=new HashMap<String,Object>();
  if (utilDebug.messageEnabled()) {
    StringBuilder message=new StringBuilder();
    Enumeration<String> requestHeaders=request.getHeaderNames();
    while (requestHeaders.hasMoreElements()) {
      String name=requestHeaders.nextElement();
      Enumeration value=(Enumeration)request.getHeaders(name);
      message.append("String_Node_Str").append(name).append("String_Node_Str").append(value).append("String_Node_Str");
    }
    utilDebug.message(message.toString());
  }
  HttpURLConnection conn=null;
  OutputStream out=null;
  String strCookies=null;
  URL authURL=null;
  try {
    String queryString=request.getQueryString();
    if (queryString != null) {
      authURL=new URL(cookieURL + "String_Node_Str" + queryString);
    }
 else {
      authURL=new URL(cookieURL);
    }
    if (utilDebug.messageEnabled()) {
      utilDebug.message("String_Node_Str" + authURL);
    }
    conn=HttpURLConnectionManager.getConnection(authURL);
    conn.setUseCaches(useCache);
    conn.setFollowRedirects(false);
    conn.setInstanceFollowRedirects(false);
    conn.setRequestProperty(ISAuthConstants.ACCEPT_LANG_HEADER,request.getHeader(ISAuthConstants.ACCEPT_LANG_HEADER));
    conn.setRequestProperty("String_Node_Str",request.getHeader("String_Node_Str"));
    List<Cookie> cookies=removeLocalLoadBalancingCookie(asList(request.getCookies()));
    strCookies=getCookiesString(cookies);
    if (strCookies != null) {
      if (utilDebug.messageEnabled()) {
        utilDebug.message("String_Node_Str" + strCookies);
      }
      conn.setRequestProperty("String_Node_Str",strCookies);
    }
    utilDebug.message("String_Node_Str");
    copyRequestHeaders(request,conn);
    if (request.getMethod().equals("String_Node_Str")) {
      conn.connect();
    }
 else {
      Map<String,Set<String>> queryParams=new HashMap<String,Set<String>>();
      if (queryString != null) {
        for (        String param : queryString.split("String_Node_Str")) {
          int idx=param.indexOf('=');
          if (idx != -1) {
            String paramName=param.substring(0,idx);
            String paramValue=param.substring(idx + 1);
            Set<String> values=queryParams.get(paramName);
            if (values == null) {
              values=new HashSet<String>();
              queryParams.put(paramName,values);
            }
            values.add(paramValue);
          }
        }
      }
      conn.setRequestProperty("String_Node_Str","String_Node_Str");
      Map<String,String[]> params=request.getParameterMap();
      Map<String,Set<String>> postParams=new HashMap<String,Set<String>>();
      for (      Map.Entry<String,String[]> entry : params.entrySet()) {
        if (queryParams.containsKey(entry.getKey())) {
        }
 else {
          Set<String> values=new HashSet<String>();
          for (          String value : entry.getValue()) {
            values.add(getCharDecodedField(value,"String_Node_Str"));
          }
          postParams.put(entry.getKey(),values);
        }
      }
      String postData=getFormData(postParams);
      if (utilDebug.messageEnabled()) {
        utilDebug.message("String_Node_Str" + postData);
      }
      if (postData.trim().length() > 0) {
        conn.setDoOutput(true);
        conn.setRequestMethod("String_Node_Str");
        out=conn.getOutputStream();
        PrintWriter pw=new PrintWriter(out);
        pw.print(postData);
        pw.flush();
        pw.close();
      }
    }
    utilDebug.message("String_Node_Str");
    if (utilDebug.messageEnabled()) {
      utilDebug.message("String_Node_Str",conn.getResponseCode(),conn.getResponseMessage());
    }
    if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
      StringBuilder in_buf=new StringBuilder();
      BufferedReader in=new BufferedReader(new InputStreamReader(conn.getInputStream(),"String_Node_Str"));
      int len;
      char[] buf=new char[1024];
      while ((len=in.read(buf,0,buf.length)) != -1) {
        in_buf.append(buf,0,len);
      }
      String in_string=in_buf.toString();
      if (utilDebug.messageEnabled()) {
        utilDebug.message("String_Node_Str" + in_string);
      }
      origRequestData.put("String_Node_Str",in_string);
    }
 else {
      utilDebug.warning("String_Node_Str");
    }
    String client_type=conn.getHeaderField("String_Node_Str");
    if (client_type != null) {
      origRequestData.put("String_Node_Str",client_type);
    }
    String redirect_url=conn.getHeaderField("String_Node_Str");
    if (redirect_url != null) {
      try {
        URL gotoURL=new URL(redirect_url);
        if (isSameServer(authURL,gotoURL)) {
          if (utilDebug.messageEnabled()) {
            utilDebug.message("String_Node_Str");
          }
          String path=gotoURL.getPath();
          String query=gotoURL.getQuery();
          redirect_url=(path != null ? path : "String_Node_Str") + (query != null ? "String_Node_Str" + gotoURL.getQuery() : "String_Node_Str");
        }
        if (utilDebug.messageEnabled()) {
          utilDebug.message("String_Node_Str" + redirect_url);
        }
        origRequestData.put("String_Node_Str",redirect_url);
      }
 catch (      MalformedURLException murle) {
        origRequestData.put("String_Node_Str",redirect_url);
      }
    }
    String content_type=conn.getHeaderField("String_Node_Str");
    if (content_type != null) {
      origRequestData.put("String_Node_Str",content_type);
    }
    origRequestData.put("String_Node_Str",conn.getResponseCode());
    copyResponseHeaders(conn.getHeaderFields(),response);
  }
 catch (  IOException ioe) {
    origRequestData.put("String_Node_Str",ioe);
  }
catch (  Exception e) {
    if (utilDebug.warningEnabled()) {
      utilDebug.warning("String_Node_Str",e);
    }
  }
 finally {
    if (out != null) {
      try {
        out.close();
      }
 catch (      IOException ioe) {
        if (utilDebug.messageEnabled()) {
          utilDebug.message("String_Node_Str",ioe);
        }
      }
    }
  }
  return origRequestData;
}