Program: 28229
Project: 28229
Buggy source:
private void doService(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 {
  if (!connector.isEnabled()) {
    String msg=MessageFormat.format(rb.getString(HTTP_LISTENER_DISABLED),String.valueOf(connector.getPort()));
    if (log.isLoggable(Level.FINE)) {
      log.log(Level.FINE,msg);
    }
    response.sendError(HttpServletResponse.SC_NOT_FOUND,msg);
    return;
  }
  if (postParseRequest(req,request,res,response,v3Enabled)) {
    boolean authPassthroughEnabled=connector.getAuthPassthroughEnabled();
    ProxyHandler proxyHandler=connector.getProxyHandler();
    if (authPassthroughEnabled && proxyHandler != null) {
      if (proxyHandler.getSSLKeysize((HttpServletRequest)request.getRequest()) > 0) {
        request.setSecure(true);
      }
      X509Certificate[] certs=null;
      try {
        certs=proxyHandler.getSSLClientCertificateChain(request.getRequest());
      }
 catch (      CertificateException ce) {
        log.log(Level.SEVERE,PARSING_CLIENT_CERT_EXCEPTION,ce);
      }
      if (certs != null) {
        request.setAttribute(Globals.CERTIFICATES_ATTR,certs);
      }
    }
    connector.requestStartEvent(request.getRequest(),request.getHost(),request.getContext());
    Container container=connector.getContainer();
    enteringServletContainer(request,response);
    try {
      request.lockSession();
      if (container.getPipeline().hasNonBasicValves() || container.hasCustomPipeline()) {
        container.getPipeline().invoke(request,response);
      }
 else {
        Host host=request.getHost();
        if (host == null) {
          response.sendError(HttpServletResponse.SC_BAD_REQUEST);
          String msg=MessageFormat.format(rb.getString(NO_HOST_MATCHES_SERVER_NAME_INFO),request.getRequest().getServerName());
          response.setDetailMessage(msg);
          return;
        }
        if (host.getPipeline().hasNonBasicValves() || host.hasCustomPipeline()) {
          host.getPipeline().invoke(request,response);
        }
 else {
          GlassFishValve hostValve=host.getPipeline().getBasic();
          hostValve.invoke(request,response);
          hostValve.postInvoke(request,response);
        }
      }
    }
  finally {
      try {
        connector.requestEndEvent(request.getRequest(),request.getHost(),request.getContext(),response.getStatus());
      }
  finally {
        try {
          request.unlockSession();
        }
  finally {
          leavingServletContainer(request,response);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void doService(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 {
  if (!connector.isEnabled()) {
    String msg=MessageFormat.format(rb.getString(HTTP_LISTENER_DISABLED),String.valueOf(connector.getPort()));
    if (log.isLoggable(Level.FINE)) {
      log.log(Level.FINE,msg);
    }
    response.sendError(HttpServletResponse.SC_NOT_FOUND,msg);
    return;
  }
  if (postParseRequest(req,request,res,response,v3Enabled)) {
    boolean authPassthroughEnabled=connector.getAuthPassthroughEnabled();
    ProxyHandler proxyHandler=connector.getProxyHandler();
    if (authPassthroughEnabled && proxyHandler != null) {
      if (proxyHandler.getSSLKeysize((HttpServletRequest)request.getRequest()) > 0) {
        request.setSecure(true);
      }
      X509Certificate[] certs=null;
      try {
        certs=proxyHandler.getSSLClientCertificateChain(request.getRequest());
      }
 catch (      CertificateException ce) {
        log.log(Level.SEVERE,PARSING_CLIENT_CERT_EXCEPTION,ce);
      }
      if (certs != null) {
        request.setAttribute(Globals.CERTIFICATES_ATTR,certs);
      }
    }
    connector.requestStartEvent(request.getRequest(),request.getHost(),request.getContext());
    Container container=connector.getContainer();
    enteringServletContainer(request,response);
    try {
      request.lockSession();
      if (container.getPipeline().hasNonBasicValves() || container.hasCustomPipeline()) {
        container.getPipeline().invoke(request,response);
      }
 else {
        Host host=request.getHost();
        if (host == null) {
          response.sendError(HttpServletResponse.SC_BAD_REQUEST);
          String msg=MessageFormat.format(rb.getString(NO_HOST_MATCHES_SERVER_NAME_INFO),request.getRequest().getServerName());
          response.setDetailMessage(msg);
          return;
        }
        if (host.getPipeline().hasNonBasicValves() || host.hasCustomPipeline()) {
          host.getPipeline().invoke(request,response);
        }
 else {
          GlassFishValve hostValve=host.getPipeline().getBasic();
          hostValve.invoke(request,response);
          hostValve.postInvoke(request,response);
        }
      }
    }
  finally {
      try {
        connector.requestEndEvent(request.getRequest(),request.getHost(),request.getContext(),response.getStatus());
      }
  finally {
        leavingServletContainer(request,response);
      }
    }
  }
}