Program: 28180
Project: 28180
Buggy source:
/** 
 * Parse additional request parameters.
 */
protected boolean postParseRequest(final org.glassfish.grizzly.http.server.Request req,final Request request,final org.glassfish.grizzly.http.server.Response res,final Response response,final boolean v3Enabled) throws Exception {
  request.setSecure(req.isSecure());
  DataChunk decodedURI=req.getRequest().getRequestURIRef().getDecodedRequestURIBC();
  if (compatWithTomcat || !v3Enabled) {
    String principal=req.getRemoteUser();
    if (principal != null) {
      request.setUserPrincipal(new CoyotePrincipal(principal));
    }
    String authtype=req.getAuthType();
    if (authtype != null) {
      request.setAuthType(authtype);
    }
  }
  final CharChunk uriParamsCC=request.getURIParams();
  final CharChunk uriCC=decodedURI.getCharChunk();
  final int semicolon=uriCC.indexOf(';');
  if (semicolon > 0) {
    final int absSemicolon=uriCC.getStart() + semicolon;
    uriParamsCC.setChars(uriCC.getBuffer(),absSemicolon,uriCC.getEnd() - absSemicolon);
    decodedURI.setChars(uriCC.getBuffer(),uriCC.getStart(),absSemicolon - uriCC.getStart());
  }
  if (compatWithTomcat || !v3Enabled) {
    DataChunk localDecodedURI=decodedURI;
    if (semicolon > 0) {
      localDecodedURI=req.getNote(DATA_CHUNK);
      if (localDecodedURI == null) {
        localDecodedURI=DataChunk.newInstance();
        req.setNote(DATA_CHUNK,localDecodedURI);
      }
      localDecodedURI.duplicate(decodedURI);
    }
    connector.getMapper().map(req.getRequest().serverName(),localDecodedURI,request.getMappingData());
    MappingData md=request.getMappingData();
    req.setNote(MAPPING_DATA,md);
    request.updatePaths(md);
  }
  String proxyName=connector.getProxyName();
  int proxyPort=connector.getProxyPort();
  if (proxyPort != 0) {
    req.setServerPort(proxyPort);
  }
  if (proxyName != null) {
    req.setServerName(proxyName);
  }
  Context ctx=(Context)request.getMappingData().context;
  if (ctx != null) {
    if (req.isRequestedSessionIdFromURL() && Globals.SESSION_PARAMETER_NAME.equals(ctx.getSessionParameterName())) {
      request.obtainSessionId();
    }
 else     if (!uriParamsCC.isNull()) {
      request.parseSessionId(ctx.getSessionParameterName(),uriParamsCC);
    }
  }
  request.setDefaultContext(request.getMappingData().isDefaultContext);
  request.setContext(ctx);
  if (ctx != null && !uriParamsCC.isNull()) {
    request.parseSessionVersion(uriParamsCC);
  }
  if (!uriParamsCC.isNull()) {
    request.parseJReplica(uriParamsCC);
  }
  request.setWrapper((Wrapper)request.getMappingData().wrapper);
  if (!connector.getAllowTrace() && Method.TRACE.equals(req.getMethod())) {
    Wrapper wrapper=request.getWrapper();
    String header=null;
    if (wrapper != null) {
      String[] methods=wrapper.getServletMethods();
      if (methods != null) {
        for (        String method : methods) {
          if ("String_Node_Str".equals(method)) {
            continue;
          }
          if (header == null) {
            header=method;
          }
 else {
            header+="String_Node_Str" + method;
          }
        }
      }
    }
    res.setStatus(405,"String_Node_Str");
    res.addHeader("String_Node_Str",header);
    return false;
  }
  DataChunk redirectPathMB=request.getMappingData().redirectPath;
  if (!redirectPathMB.isNull() && (!ctx.hasAdHocPaths() || (ctx.getAdHocServletName(((HttpServletRequest)request.getRequest()).getServletPath()) == null))) {
    String redirectPath=redirectPathMB.toString();
    String query=request.getQueryString();
    if (request.isRequestedSessionIdFromURL()) {
      redirectPath=redirectPath + "String_Node_Str" + ctx.getSessionParameterName()+ "String_Node_Str"+ request.getRequestedSessionId();
    }
    redirectPath=response.encode(redirectPath);
    if (query != null) {
      redirectPath=redirectPath + "String_Node_Str" + query;
    }
    boolean authPassthroughEnabled=connector.getAuthPassthroughEnabled();
    ProxyHandler proxyHandler=connector.getProxyHandler();
    if (authPassthroughEnabled && proxyHandler != null) {
      if (proxyHandler.getSSLKeysize((HttpServletRequest)request.getRequest()) > 0) {
        request.setSecure(true);
      }
    }
    response.sendRedirect(redirectPath,false);
    return false;
  }
  request.parseSessionCookiesId();
  request.parseJrouteCookie();
  return true;
}

Fixed version (ground truth):
/** 
 * Parse additional request parameters.
 */
protected boolean postParseRequest(final org.glassfish.grizzly.http.server.Request req,final Request request,final org.glassfish.grizzly.http.server.Response res,final Response response,final boolean v3Enabled) throws Exception {
  request.setSecure(req.isSecure());
  DataChunk decodedURI;
  try {
    decodedURI=req.getRequest().getRequestURIRef().getDecodedRequestURIBC();
  }
 catch (  CharConversionException cce) {
    response.sendError(HttpServletResponse.SC_BAD_REQUEST,"String_Node_Str");
    return false;
  }
  if (compatWithTomcat || !v3Enabled) {
    String principal=req.getRemoteUser();
    if (principal != null) {
      request.setUserPrincipal(new CoyotePrincipal(principal));
    }
    String authtype=req.getAuthType();
    if (authtype != null) {
      request.setAuthType(authtype);
    }
  }
  final CharChunk uriParamsCC=request.getURIParams();
  final CharChunk uriCC=decodedURI.getCharChunk();
  final int semicolon=uriCC.indexOf(';');
  if (semicolon > 0) {
    final int absSemicolon=uriCC.getStart() + semicolon;
    uriParamsCC.setChars(uriCC.getBuffer(),absSemicolon,uriCC.getEnd() - absSemicolon);
    decodedURI.setChars(uriCC.getBuffer(),uriCC.getStart(),absSemicolon - uriCC.getStart());
  }
  if (compatWithTomcat || !v3Enabled) {
    DataChunk localDecodedURI=decodedURI;
    if (semicolon > 0) {
      localDecodedURI=req.getNote(DATA_CHUNK);
      if (localDecodedURI == null) {
        localDecodedURI=DataChunk.newInstance();
        req.setNote(DATA_CHUNK,localDecodedURI);
      }
      localDecodedURI.duplicate(decodedURI);
    }
    connector.getMapper().map(req.getRequest().serverName(),localDecodedURI,request.getMappingData());
    MappingData md=request.getMappingData();
    req.setNote(MAPPING_DATA,md);
    request.updatePaths(md);
  }
  String proxyName=connector.getProxyName();
  int proxyPort=connector.getProxyPort();
  if (proxyPort != 0) {
    req.setServerPort(proxyPort);
  }
  if (proxyName != null) {
    req.setServerName(proxyName);
  }
  Context ctx=(Context)request.getMappingData().context;
  if (ctx != null) {
    if (req.isRequestedSessionIdFromURL() && Globals.SESSION_PARAMETER_NAME.equals(ctx.getSessionParameterName())) {
      request.obtainSessionId();
    }
 else     if (!uriParamsCC.isNull()) {
      request.parseSessionId(ctx.getSessionParameterName(),uriParamsCC);
    }
  }
  request.setDefaultContext(request.getMappingData().isDefaultContext);
  request.setContext(ctx);
  if (ctx != null && !uriParamsCC.isNull()) {
    request.parseSessionVersion(uriParamsCC);
  }
  if (!uriParamsCC.isNull()) {
    request.parseJReplica(uriParamsCC);
  }
  request.setWrapper((Wrapper)request.getMappingData().wrapper);
  if (!connector.getAllowTrace() && Method.TRACE.equals(req.getMethod())) {
    Wrapper wrapper=request.getWrapper();
    String header=null;
    if (wrapper != null) {
      String[] methods=wrapper.getServletMethods();
      if (methods != null) {
        for (        String method : methods) {
          if ("String_Node_Str".equals(method)) {
            continue;
          }
          if (header == null) {
            header=method;
          }
 else {
            header+="String_Node_Str" + method;
          }
        }
      }
    }
    res.setStatus(405,"String_Node_Str");
    res.addHeader("String_Node_Str",header);
    return false;
  }
  DataChunk redirectPathMB=request.getMappingData().redirectPath;
  if (!redirectPathMB.isNull() && (!ctx.hasAdHocPaths() || (ctx.getAdHocServletName(((HttpServletRequest)request.getRequest()).getServletPath()) == null))) {
    String redirectPath=redirectPathMB.toString();
    String query=request.getQueryString();
    if (request.isRequestedSessionIdFromURL()) {
      redirectPath=redirectPath + "String_Node_Str" + ctx.getSessionParameterName()+ "String_Node_Str"+ request.getRequestedSessionId();
    }
    redirectPath=response.encode(redirectPath);
    if (query != null) {
      redirectPath=redirectPath + "String_Node_Str" + query;
    }
    boolean authPassthroughEnabled=connector.getAuthPassthroughEnabled();
    ProxyHandler proxyHandler=connector.getProxyHandler();
    if (authPassthroughEnabled && proxyHandler != null) {
      if (proxyHandler.getSSLKeysize((HttpServletRequest)request.getRequest()) > 0) {
        request.setSecure(true);
      }
    }
    response.sendRedirect(redirectPath,false);
    return false;
  }
  request.parseSessionCookiesId();
  request.parseJrouteCookie();
  return true;
}