Program: 28670
Project: 28670
Buggy source:
/** 
 * Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL.  If this URL is already absolute, return it unchanged.
 * @param location URL to be (possibly) converted and then returned
 * @exception IllegalArgumentException if a MalformedURLException isthrown when converting the relative URL to an absolute one
 */
protected String toAbsolute(String location){
  if (location == null)   return location;
  boolean leadingSlash=location.startsWith("String_Node_Str");
  if (location.startsWith("String_Node_Str")) {
    redirectURLCC.recycle();
    String scheme=getRedirectScheme();
    try {
      redirectURLCC.append(scheme,0,scheme.length());
      redirectURLCC.append(':');
      redirectURLCC.append(location,0,location.length());
      return redirectURLCC.toString();
    }
 catch (    IOException e) {
      IllegalArgumentException iae=new IllegalArgumentException(location);
      iae.initCause(e);
      throw iae;
    }
  }
 else   if (leadingSlash || (location.indexOf("String_Node_Str") == -1)) {
    redirectURLCC.recycle();
    String scheme=getRedirectScheme();
    String name=request.getServerName();
    int port=request.getServerPort();
    try {
      redirectURLCC.append(scheme,0,scheme.length());
      redirectURLCC.append("String_Node_Str",0,3);
      redirectURLCC.append(name,0,name.length());
      if (scheme.equals("String_Node_Str") && port != 80 || scheme.equals("String_Node_Str") && port != 443) {
        redirectURLCC.append(':');
        String portS=port + "String_Node_Str";
        redirectURLCC.append(portS,0,portS.length());
      }
      if (!leadingSlash) {
        String relativePath=request.getDecodedRequestURI();
        int pos=relativePath.lastIndexOf('/');
        relativePath=relativePath.substring(0,pos);
        String encodedURI=null;
        final String frelativePath=relativePath;
        if (SecurityUtil.isPackageProtectionEnabled()) {
          try {
            encodedURI=AccessController.doPrivileged(new PrivilegedExceptionAction<String>(){
              public String run() throws IOException {
                return urlEncoder.encodeURL(frelativePath);
              }
            }
);
          }
 catch (          PrivilegedActionException pae) {
            IllegalArgumentException iae=new IllegalArgumentException(location);
            iae.initCause(pae.getCause());
            throw iae;
          }
        }
 else {
          encodedURI=urlEncoder.encodeURL(relativePath);
        }
        redirectURLCC.append(encodedURI,0,encodedURI.length());
        redirectURLCC.append('/');
      }
      redirectURLCC.append(location,0,location.length());
    }
 catch (    IOException e) {
      IllegalArgumentException iae=new IllegalArgumentException(location);
      iae.initCause(e);
      throw iae;
    }
    return redirectURLCC.toString();
  }
 else {
    return location;
  }
}

Fixed version (ground truth):
/** 
 * Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL.  If this URL is already absolute, return it unchanged.
 * @param location URL to be (possibly) converted and then returned
 * @exception IllegalArgumentException if a MalformedURLException isthrown when converting the relative URL to an absolute one
 */
protected String toAbsolute(String location){
  if (location == null)   return location;
  boolean leadingSlash=location.startsWith("String_Node_Str");
  if (location.startsWith("String_Node_Str")) {
    redirectURLCC.recycle();
    String scheme=getRedirectScheme();
    try {
      redirectURLCC.append(scheme,0,scheme.length());
      redirectURLCC.append(':');
      redirectURLCC.append(location,0,location.length());
      return redirectURLCC.toString();
    }
 catch (    IOException e) {
      IllegalArgumentException iae=new IllegalArgumentException(location);
      iae.initCause(e);
      throw iae;
    }
  }
 else   if (leadingSlash || (location.indexOf("String_Node_Str") == -1)) {
    redirectURLCC.recycle();
    String scheme=getRedirectScheme();
    String name=request.getServerName();
    int port=request.getServerPort();
    try {
      redirectURLCC.append(scheme,0,scheme.length());
      redirectURLCC.append("String_Node_Str",0,3);
      redirectURLCC.append(name,0,name.length());
      if (scheme.equals("String_Node_Str") && port != 80 || scheme.equals("String_Node_Str") && port != 443) {
        redirectURLCC.append(':');
        String portS=port + "String_Node_Str";
        redirectURLCC.append(portS,0,portS.length());
      }
      if (!leadingSlash) {
        String relativePath=request.getDecodedRequestURI();
        int pos=relativePath.lastIndexOf('/');
        relativePath=relativePath.substring(0,pos);
        String encodedURI=null;
        final String frelativePath=relativePath;
        if (SecurityUtil.isPackageProtectionEnabled()) {
          try {
            encodedURI=AccessController.doPrivileged(new PrivilegedExceptionAction<String>(){
              public String run() throws IOException {
                return urlEncoder.encodeURL(frelativePath);
              }
            }
);
          }
 catch (          PrivilegedActionException pae) {
            IllegalArgumentException iae=new IllegalArgumentException(location);
            iae.initCause(pae.getCause());
            throw iae;
          }
        }
 else {
          encodedURI=urlEncoder.encodeURL(relativePath);
        }
        redirectURLCC.append(encodedURI,0,encodedURI.length());
        redirectURLCC.append('/');
      }
      redirectURLCC.append(location,0,location.length());
      normalize(redirectURLCC);
    }
 catch (    IOException e) {
      IllegalArgumentException iae=new IllegalArgumentException(location);
      iae.initCause(e);
      throw iae;
    }
    return redirectURLCC.toString();
  }
 else {
    return location;
  }
}