Refactoring

Signed-off-by: Arjan Tijms <arjan.tijms@gmail.com>
diff --git a/appserver/featuresets/debug/pom.xml b/appserver/featuresets/debug/pom.xml
index 03e577a..fd8c813 100644
--- a/appserver/featuresets/debug/pom.xml
+++ b/appserver/featuresets/debug/pom.xml
@@ -62,6 +62,27 @@
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.framework</artifactId>
         </dependency>
+        
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-framework</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-portunif</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-http</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-http2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-http-server</artifactId>
+        </dependency>
 
         <dependency>
             <groupId>org.glassfish.main.featuresets</groupId>
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
index d0b11fd..f02578a 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/CoyoteAdapter.java
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
  * Copyright (c) 1997-2018 Oracle and/or its affiliates. All rights reserved.
  * Copyright 2004 The Apache Software Foundation
  *
@@ -17,19 +18,30 @@
 
 package org.apache.catalina.connector;
 
+import static jakarta.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
+import static jakarta.servlet.http.HttpServletResponse.SC_NOT_FOUND;
+import static java.util.logging.Level.FINE;
+import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.SEVERE;
+import static org.apache.catalina.Globals.SESSION_PARAMETER_NAME;
+import static org.apache.catalina.LogFacade.FAILED_TO_INITIALIZE_THE_INTERCEPTOR;
+import static org.apache.catalina.LogFacade.HTTP_LISTENER_DISABLED;
+import static org.apache.catalina.LogFacade.INTERNAL_ERROR;
+import static org.apache.catalina.LogFacade.NO_HOST_MATCHES_SERVER_NAME_INFO;
+import static org.apache.catalina.LogFacade.PARSING_CLIENT_CERT_EXCEPTION;
+import static org.apache.catalina.LogFacade.REQUEST_PROCESSING_EXCEPTION;
+import static org.apache.catalina.connector.Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER;
+import static org.glassfish.internal.api.Globals.getDefaultHabitat;
+
+import java.io.CharConversionException;
 import java.nio.charset.Charset;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
 import java.text.MessageFormat;
 import java.util.Collection;
 import java.util.ResourceBundle;
-import java.util.logging.Level;
 import java.util.logging.Logger;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
 
-import com.sun.appserv.ProxyHandler;
-import java.io.CharConversionException;
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
@@ -37,26 +49,24 @@
 import org.apache.catalina.LogFacade;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.core.ContainerBase;
-import org.apache.catalina.util.ResponseUtil;
 import org.apache.catalina.util.ServerInfo;
-import org.apache.catalina.util.StringManager;
 import org.glassfish.common.util.InputValidationUtil;
 import org.glassfish.grizzly.http.Method;
+import org.glassfish.grizzly.http.Note;
 import org.glassfish.grizzly.http.server.AfterServiceListener;
 import org.glassfish.grizzly.http.server.HttpHandler;
-import org.glassfish.grizzly.http.Note;
 import org.glassfish.grizzly.http.server.util.MappingData;
 import org.glassfish.grizzly.http.util.ByteChunk;
 import org.glassfish.grizzly.http.util.CharChunk;
 import org.glassfish.grizzly.http.util.DataChunk;
 import org.glassfish.grizzly.http.util.MessageBytes;
-import org.glassfish.hk2.api.ServiceLocator;
 import org.glassfish.web.valve.GlassFishValve;
 import org.glassfish.web.valve.ServletContainerInterceptor;
 
+import com.sun.appserv.ProxyHandler;
+
 /**
- * Implementation of a request processor which delegates the processing to a
- * Coyote processor.
+ * Implementation of a request processor which delegates the processing to a Coyote processor.
  *
  * @author Craig R. McClanahan
  * @author Remy Maucherat
@@ -69,59 +79,51 @@
     private static final ResourceBundle rb = log.getResourceBundle();
 
     // -------------------------------------------------------------- Constants
-    private static final String POWERED_BY = "Servlet/3.1 JSP/2.3 " +
-            "(" + ServerInfo.getServerInfo() + " Java/" +
-            System.getProperty("java.vm.vendor") + "/" +
-            System.getProperty("java.specification.version") + ")";
-
-
-//    protected boolean v3Enabled =
-//        Boolean.valueOf(System.getProperty("v3.grizzly.useMapper", "true"));
-
-
-//    public static final int ADAPTER_NOTES = 1;
 
     static final String JVM_ROUTE = System.getProperty("jvmRoute");
 
-    private Collection<ServletContainerInterceptor> interceptors = null;
-
     protected static final boolean ALLOW_BACKSLASH =
         Boolean.valueOf(System.getProperty("org.glassfish.grizzly.tcp.tomcat5.CoyoteAdapter.ALLOW_BACKSLASH", "false"));
 
     private static final boolean COLLAPSE_ADJACENT_SLASHES =
-        Boolean.valueOf(System.getProperty(
-            "com.sun.enterprise.web.collapseAdjacentSlashes", "true"));
-
-    /**
-     * When mod_jk is used, the adapter must be invoked the same way
-     * Tomcat does by invoking service(...) and the afterService(...). This
-     * is a hack to make it compatible with Tomcat 5|6.
-     */
-    private boolean compatWithTomcat = false;
-
-    private String serverName = ServerInfo.getPublicServerInfo();
+        Boolean.valueOf(System.getProperty("com.sun.enterprise.web.collapseAdjacentSlashes", "true"));
 
     // Make sure this value is always aligned with {@link ContainerMapper}
     // (@see com.sun.enterprise.v3.service.impl.ContainerMapper)
-    protected final static Note<MappingData> MAPPING_DATA =
-            org.glassfish.grizzly.http.server.Request.<MappingData>createNote("MappingData");
-
+    protected static final Note<MappingData> MAPPING_DATA =
+        org.glassfish.grizzly.http.server.Request.<MappingData>createNote("MappingData");
     static final Note<Request> CATALINA_REQUEST_NOTE =
-            org.glassfish.grizzly.http.server.Request.createNote(Request.class.getName());
+        org.glassfish.grizzly.http.server.Request.createNote(Request.class.getName());
     static final Note<Response> CATALINA_RESPONSE_NOTE =
-            org.glassfish.grizzly.http.server.Request.createNote(Response.class.getName());
+        org.glassfish.grizzly.http.server.Request.createNote(Response.class.getName());
 
-    static final CatalinaAfterServiceListener catalinaAfterServiceListener =
-            new CatalinaAfterServiceListener();
+    static final CatalinaAfterServiceListener catalinaAfterServiceListener = new CatalinaAfterServiceListener();
 
     // Make sure this value is always aligned with {@link ContainerMapper}
     // (@see com.sun.enterprise.v3.service.impl.ContainerMapper)
     private final static Note<DataChunk> DATA_CHUNK =
-            org.glassfish.grizzly.http.server.Request.<DataChunk>createNote("DataChunk");
+        org.glassfish.grizzly.http.server.Request.<DataChunk>createNote("DataChunk");
+
+    // ----------------------------------------------------- Instance Variables
+
+    private Collection<ServletContainerInterceptor> interceptors;
+
+    /**
+     * When mod_jk is used, the adapter must be invoked the same way Tomcat does by invoking service(...) and the
+     * afterService(...). This is a hack to make it compatible with Tomcat 5|6.
+     */
+    private boolean compatWithTomcat;
+
+    private String serverName = ServerInfo.getPublicServerInfo();
+
+    /**
+     * The CoyoteConnector with which this processor is associated.
+     */
+    private Connector connector;
+
 
     // ----------------------------------------------------------- Constructors
 
-
     /**
      * Construct a new CoyoteProcessor associated with the specified connector.
      *
@@ -134,213 +136,171 @@
     }
 
 
-    // ----------------------------------------------------- Instance Variables
-
-
-    /**
-     * The CoyoteConnector with which this processor is associated.
-     */
-    private Connector connector = null;
-
-
     // -------------------------------------------------------- Adapter Methods
 
-
     /**
      * Service method.
      */
     @Override
-    public void service(org.glassfish.grizzly.http.server.Request req,
-                        org.glassfish.grizzly.http.server.Response res)
-            throws Exception {
+    public void service(org.glassfish.grizzly.http.server.Request grizzlyRequest, org.glassfish.grizzly.http.server.Response grizzlyResponse) throws Exception {
+        grizzlyResponse.getResponse().setAllowCustomReasonPhrase(USE_CUSTOM_STATUS_MSG_IN_HEADER);
 
-        res.getResponse().setAllowCustomReasonPhrase(Constants.USE_CUSTOM_STATUS_MSG_IN_HEADER);
-
-        Request request = req.getNote(CATALINA_REQUEST_NOTE);
-        Response response = req.getNote(CATALINA_RESPONSE_NOTE);
+        Request catalinaRequest = grizzlyRequest.getNote(CATALINA_REQUEST_NOTE);
+        Response catalinaResponse = grizzlyRequest.getNote(CATALINA_RESPONSE_NOTE);
 
         // Grizzly already parsed, decoded, and mapped the request.
         // Let's re-use this info here, before firing the
         // requestStartEvent probe, so that the mapping data will be
         // available to any probe event listener via standard
         // ServletRequest APIs (such as getContextPath())
-        MappingData md = req.getNote(MAPPING_DATA);
-        final boolean v3Enabled = md != null;
-        if (request == null) {
+        MappingData mappingData = grizzlyRequest.getNote(MAPPING_DATA);
+        final boolean v3Enabled = mappingData != null;
+        if (catalinaRequest == null) {
 
             // Create objects
-            request = (Request) connector.createRequest();
-            response = (Response) connector.createResponse();
+            catalinaRequest = (Request) connector.createRequest();
+            catalinaResponse = (Response) connector.createResponse();
 
             // Link objects
-            request.setResponse(response);
-            response.setRequest(request);
+            catalinaRequest.setResponse(catalinaResponse);
+            catalinaResponse.setRequest(catalinaRequest);
 
             // Set as notes
-            req.setNote(CATALINA_REQUEST_NOTE, request);
-            req.setNote(CATALINA_RESPONSE_NOTE, response);
-//            res.setNote(ADAPTER_NOTES, response);
+            grizzlyRequest.setNote(CATALINA_REQUEST_NOTE, catalinaRequest);
+            grizzlyRequest.setNote(CATALINA_RESPONSE_NOTE, catalinaResponse);
 
             // Set query string encoding
-            req.getRequest().getRequestURIRef().setDefaultURIEncoding(Charset.forName(connector.getURIEncoding()));
+            grizzlyRequest.getRequest().getRequestURIRef().setDefaultURIEncoding(Charset.forName(connector.getURIEncoding()));
         }
 
-        request.setCoyoteRequest(req);
-        response.setCoyoteResponse(res);
+        catalinaRequest.setGrizzlyRequest(grizzlyRequest);
+        catalinaResponse.setCoyoteResponse(grizzlyResponse);
 
         if (v3Enabled && !compatWithTomcat) {
-            request.setMappingData(md);
-            request.updatePaths(md);
+            catalinaRequest.setMappingData(mappingData);
+            catalinaRequest.updatePaths(mappingData);
         }
 
-        req.addAfterServiceListener(catalinaAfterServiceListener);
+        grizzlyRequest.addAfterServiceListener(catalinaAfterServiceListener);
 
         try {
-            doService(req, request, res, response, v3Enabled);
+            doService(grizzlyRequest, catalinaRequest, grizzlyResponse, catalinaResponse, v3Enabled);
 
             // Request may want to initialize async processing
-            request.onExitService();
+            catalinaRequest.onExitService();
         } catch (Throwable t) {
-            log.log(Level.SEVERE, LogFacade.REQUEST_PROCESSING_EXCEPTION, t);
+            log.log(SEVERE, REQUEST_PROCESSING_EXCEPTION, t);
         }
     }
 
     private void enteringServletContainer(Request req, Response res) {
-        if (interceptors == null)
+        if (interceptors == null) {
             return;
-        for(ServletContainerInterceptor interceptor:interceptors) {
-            try{
+        }
+
+        for (ServletContainerInterceptor interceptor : interceptors) {
+            try {
                 interceptor.preInvoke(req, res);
             } catch (Throwable th) {
-                log.log(Level.SEVERE, LogFacade.INTERNAL_ERROR, th);
+                log.log(SEVERE, INTERNAL_ERROR, th);
             }
         }
     }
 
     private void leavingServletContainer(Request req, Response res) {
-        if (interceptors == null)
+        if (interceptors == null) {
             return;
-        for(ServletContainerInterceptor interceptor:interceptors) {
-            try{
+        }
+
+        for (ServletContainerInterceptor interceptor : interceptors) {
+            try {
                 interceptor.postInvoke(req, res);
             } catch (Throwable th) {
-                log.log(Level.SEVERE, LogFacade.INTERNAL_ERROR, th);
+                log.log(SEVERE, INTERNAL_ERROR, th);
             }
         }
     }
 
     private void initServletInterceptors() {
         try {
-            ServiceLocator services = org.glassfish.internal.api.Globals.getDefaultHabitat();
-            interceptors = services.getAllServices(ServletContainerInterceptor.class);
+            interceptors = getDefaultHabitat().getAllServices(ServletContainerInterceptor.class);
         } catch (Throwable th) {
-            log.log(Level.SEVERE, LogFacade.FAILED_TO_INITIALIZE_THE_INTERCEPTOR, th);
+            log.log(SEVERE, FAILED_TO_INITIALIZE_THE_INTERCEPTOR, th);
         }
     }
 
+    private void doService(
+        final org.glassfish.grizzly.http.server.Request grizzlyRequest, final Request catalinaRequest,
+        final org.glassfish.grizzly.http.server.Response grizzlyResponse, final Response catalinaResponse, final boolean v3Enabled) throws Exception {
 
-    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 {
-
-        // START SJSAS 6331392
         // Check connector for disabled state
         if (!connector.isEnabled()) {
-            String msg = MessageFormat.format(rb.getString(LogFacade.HTTP_LISTENER_DISABLED),
-                                              String.valueOf(connector.getPort()));
-            if (log.isLoggable(Level.FINE)) {
-                log.log(Level.FINE, msg);
+            String msg = MessageFormat.format(rb.getString(HTTP_LISTENER_DISABLED), String.valueOf(connector.getPort()));
+            if (log.isLoggable(FINE)) {
+                log.log(FINE, msg);
             }
-            response.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+            catalinaResponse.sendError(SC_NOT_FOUND, msg);
             return;
         }
-        // END SJSAS 6331392
 
-////            "X-Powered-By" header is set by GlassfishHttpCodecFilter
-//        if (connector.isXpoweredBy()) {
-//            response.addHeader("X-Powered-By", POWERED_BY);
-//        }
+        // Parse and set Catalina and configuration specific request parameters
+        if (postParseRequest(grizzlyRequest, catalinaRequest, grizzlyResponse, catalinaResponse, v3Enabled)) {
 
-
-        // Parse and set Catalina and configuration specific
-        // request parameters
-        if ( postParseRequest(req, request, res, response, v3Enabled) ) {
-
-            // START S1AS 6188932
-            boolean authPassthroughEnabled =
-                connector.getAuthPassthroughEnabled();
+            boolean authPassthroughEnabled = connector.getAuthPassthroughEnabled();
             ProxyHandler proxyHandler = connector.getProxyHandler();
             if (authPassthroughEnabled && proxyHandler != null) {
 
-                // START SJSAS 6397218
-                if (proxyHandler.getSSLKeysize(
-                        (HttpServletRequest)request.getRequest()) > 0) {
-                    request.setSecure(true);
+                // Otherwise Servlet request.isSecure() value is not propagated when authPassthroughEnabled is set to true
+                if (proxyHandler.getSSLKeysize(catalinaRequest.getRequest()) > 0) {
+                    catalinaRequest.setSecure(true);
                 }
-                // END SJSAS 6397218
 
                 X509Certificate[] certs = null;
                 try {
-                    certs = proxyHandler.getSSLClientCertificateChain(
-                                request.getRequest());
+                    certs = proxyHandler.getSSLClientCertificateChain(catalinaRequest.getRequest());
                 } catch (CertificateException ce) {
-                    log.log(Level.SEVERE, LogFacade.PARSING_CLIENT_CERT_EXCEPTION,
-                            ce);
+                    log.log(SEVERE, PARSING_CLIENT_CERT_EXCEPTION, ce);
                 }
                 if (certs != null) {
-                    request.setAttribute(Globals.CERTIFICATES_ATTR,
-                                         certs);
+                    catalinaRequest.setAttribute(Globals.CERTIFICATES_ATTR, certs);
                 }
 
             }
-            // END S1AS 6188932
-
-////            "Server" header is set by GlassfishHttpCodecFilter
-//            if (serverName != null && !serverName.isEmpty()) {
-//                response.addHeader("Server", serverName);
-//            }
 
             // Invoke the web container
-            connector.requestStartEvent(request.getRequest(),
-                request.getHost(), request.getContext());
+            connector.requestStartEvent(catalinaRequest.getRequest(), catalinaRequest.getHost(), catalinaRequest.getContext());
             Container container = connector.getContainer();
-            enteringServletContainer(request, response);
+            enteringServletContainer(catalinaRequest, catalinaResponse);
             try {
-                request.lockSession();
-                if (container.getPipeline().hasNonBasicValves() ||
-                        container.hasCustomPipeline()) {
-                    container.getPipeline().invoke(request, response);
+                catalinaRequest.lockSession();
+                if (container.getPipeline().hasNonBasicValves() || container.hasCustomPipeline()) {
+                    container.getPipeline().invoke(catalinaRequest, catalinaResponse);
                 } else {
                     // Invoke host directly
-                    Host host = request.getHost();
+                    Host host = catalinaRequest.getHost();
                     if (host == null) {
-                        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
-
-                        String msg = MessageFormat.format(rb.getString(LogFacade.NO_HOST_MATCHES_SERVER_NAME_INFO),
-                                                          request.getRequest().getServerName());
-                        response.setDetailMessage(msg);
+                        catalinaResponse.sendError(SC_BAD_REQUEST);
+                        catalinaResponse.setDetailMessage(
+                            MessageFormat.format(
+                                rb.getString(NO_HOST_MATCHES_SERVER_NAME_INFO),
+                                catalinaRequest.getRequest().getServerName()));
                         return;
                     }
-                    if (host.getPipeline().hasNonBasicValves() ||
-                            host.hasCustomPipeline()) {
-                        host.getPipeline().invoke(request, response);
+
+                    if (host.getPipeline().hasNonBasicValves() || host.hasCustomPipeline()) {
+                        host.getPipeline().invoke(catalinaRequest, catalinaResponse);
                     } else {
                         GlassFishValve hostValve = host.getPipeline().getBasic();
-                        hostValve.invoke(request, response);
+                        hostValve.invoke(catalinaRequest, catalinaResponse);
                         // Error handling
-                        hostValve.postInvoke(request, response);
+                        hostValve.postInvoke(catalinaRequest, catalinaResponse);
                     }
                 }
             } finally {
                 try {
-                    connector.requestEndEvent(request.getRequest(),
-                        request.getHost(), request.getContext(),
-                        response.getStatus());
+                    connector.requestEndEvent(catalinaRequest.getRequest(), catalinaRequest.getHost(), catalinaRequest.getContext(), catalinaResponse.getStatus());
                 } finally {
-                    leavingServletContainer(request, response);
+                    leavingServletContainer(catalinaRequest, catalinaResponse);
                 }
             }
         }
@@ -348,170 +308,117 @@
     }
     // ------------------------------------------------------ Protected Methods
 
-
     /**
      * 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 {
+    protected boolean postParseRequest(
+        final org.glassfish.grizzly.http.server.Request grizzlyRequest, final Request catalinaRequest,
+        final org.glassfish.grizzly.http.server.Response grizzlyResponse, final Response catalinaResponse, final boolean v3Enabled) throws Exception {
+
         // XXX the processor may have set a correct scheme and port prior to this point,
         // in ajp13 protocols dont make sense to get the port from the connector...
         // otherwise, use connector configuration
-        request.setSecure(req.isSecure());
+        catalinaRequest.setSecure(grizzlyRequest.isSecure());
 
         // URI decoding
         DataChunk decodedURI;
         try {
-            decodedURI = req.getRequest().getRequestURIRef().getDecodedRequestURIBC();
+            decodedURI = grizzlyRequest.getRequest().getRequestURIRef().getDecodedRequestURIBC();
         } catch (CharConversionException cce) {
-            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid URI");
+            catalinaResponse.sendError(SC_BAD_REQUEST, "Invalid URI");
             return false;
         }
 
         if (compatWithTomcat || !v3Enabled) {
-//            decodedURI.duplicate(req.requestURI());
-//            try {
-//              req.getURLDecoder().convert(decodedURI, false);
-//            } catch (IOException ioe) {
-//              res.setStatus(400);
-//              res.setMessage("Invalid URI: " + ioe.getMessage());
-//              return false;
-//            }
-
-            /* GlassFish Issue 2339
-            // Normalize decoded URI
-            if (!normalize(req.decodedURI())) {
-                res.setStatus(400);
-                res.setMessage("Invalid URI");
-                return false;
-            }
-            */
 
             // Set the remote principal
-            String principal = req.getRemoteUser();
+            String principal = grizzlyRequest.getRemoteUser();
             if (principal != null) {
-                request.setUserPrincipal(new CoyotePrincipal(principal));
+                catalinaRequest.setUserPrincipal(new CoyotePrincipal(principal));
             }
 
             // Set the authorization type
-            String authtype = req.getAuthType();
+            String authtype = grizzlyRequest.getAuthType();
             if (authtype != null) {
-                request.setAuthType(authtype);
+                catalinaRequest.setAuthType(authtype);
             }
-
-            /* CR 6309511
-            // URI character decoding
-            convertURI(decodedURI, request);
-
-            // Parse session Id
-            parseSessionId(req, request);
-             */
-            // START CR 6309511
-//             URI character decoding
-//            request.convertURI(decodedURI);
-
-            // START GlassFish Issue 2339
-            // Normalize decoded URI
-//            if (!normalize(decodedURI)) {
-//                res.setStatus(400);
-//                res.setMessage("Invalid URI");
-//                return false;
-//            }
-            // END GlassFish Issue 2339
         }
-        // END CR 6309511
 
         /*
-         * Remove any parameters from the URI, so they won't be considered
-         * by the mapping algorithm, and save them in a temporary CharChunk,
-         * so that any session id param may be parsed once the target
-         * context, which may use a custom session parameter name, has been
-         * identified
+         * Remove any parameters from the URI, so they won't be considered by the mapping algorithm, and save them in a
+         * temporary CharChunk, so that any session id param may be parsed once the target context, which may use a custom
+         * session parameter name, has been identified
          */
-        final CharChunk uriParamsCC = request.getURIParams();
+        final CharChunk uriParamsCC = catalinaRequest.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());
+            uriParamsCC.setChars(uriCC.getBuffer(), absSemicolon, uriCC.getEnd() - absSemicolon);
+            decodedURI.setChars(uriCC.getBuffer(), uriCC.getStart(), absSemicolon - uriCC.getStart());
         }
 
         if (compatWithTomcat || !v3Enabled) {
-            /*mod_jk*/
+            /* mod_jk */
             DataChunk localDecodedURI = decodedURI;
             if (semicolon > 0) {
-                localDecodedURI = req.getNote(DATA_CHUNK);
+                localDecodedURI = grizzlyRequest.getNote(DATA_CHUNK);
                 if (localDecodedURI == null) {
                     localDecodedURI = DataChunk.newInstance();
-                    req.setNote(DATA_CHUNK, localDecodedURI);
+                    grizzlyRequest.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);
+
+            connector.getMapper()
+                     .map(
+                       grizzlyRequest.getRequest().serverName(),
+                       localDecodedURI,
+                       catalinaRequest.getMappingData());
+
+            MappingData md = catalinaRequest.getMappingData();
+            grizzlyRequest.setNote(MAPPING_DATA, md);
+            catalinaRequest.updatePaths(md);
         }
 
-        // FIXME: the code below doesnt belongs to here,
-        // this is only have sense
-        // in Http11, not in ajp13..
-        // At this point the Host header has been processed.
-        // Override if the proxyPort/proxyHost are set
+        // FIXME: the code below doesn't belongs to here, this is only have sense in Http11, not in ajp13..
+        // At this point the Host header has been processed. Override if the proxyPort/proxyHost are set
         String proxyName = connector.getProxyName();
         int proxyPort = connector.getProxyPort();
         if (proxyPort != 0) {
-            req.setServerPort(proxyPort);
+            grizzlyRequest.setServerPort(proxyPort);
         }
         if (proxyName != null) {
-            req.setServerName(proxyName);
+            grizzlyRequest.setServerName(proxyName);
         }
 
-        Context ctx = (Context) request.getMappingData().context;
+        Context catalinaContext = (Context) catalinaRequest.getMappingData().context;
 
         // Parse session id
-        if (ctx != null) {
-            if (req.isRequestedSessionIdFromURL() &&
-                    Globals.SESSION_PARAMETER_NAME.equals(ctx.getSessionParameterName())) {
-                request.obtainSessionId();
+        if (catalinaContext != null) {
+            if (grizzlyRequest.isRequestedSessionIdFromURL() && SESSION_PARAMETER_NAME.equals(catalinaContext.getSessionParameterName())) {
+                catalinaRequest.obtainSessionId();
             } else if (!uriParamsCC.isNull()) {
-//            String sessionParam = ";" + ctx.getSessionParameterName() + "=";
-                request.parseSessionId(ctx.getSessionParameterName(), uriParamsCC);
+                catalinaRequest.parseSessionId(catalinaContext.getSessionParameterName(), uriParamsCC);
             }
         }
 
-        // START GlassFish 1024
-        request.setDefaultContext(request.getMappingData().isDefaultContext);
-        // END GlassFish 1024
+        catalinaRequest.setDefaultContext(catalinaRequest.getMappingData().isDefaultContext);
+        catalinaRequest.setContext(catalinaContext);
 
-        // START SJSAS 6253524
-        // request.setContext((Context) request.getMappingData().context);
-        // END SJSAS 6253524
-        // START SJSAS 6253524
-        request.setContext(ctx);
-        // END SJSAS 6253524
-
-        if (ctx != null && !uriParamsCC.isNull()) {
-            request.parseSessionVersion(uriParamsCC);
+        if (catalinaContext != null && !uriParamsCC.isNull()) {
+            catalinaRequest.parseSessionVersion(uriParamsCC);
         }
 
         if (!uriParamsCC.isNull()) {
-            request.parseJReplica(uriParamsCC);
+            catalinaRequest.parseJReplica(uriParamsCC);
         }
 
-        request.setWrapper((Wrapper) request.getMappingData().wrapper);
+        catalinaRequest.setWrapper((Wrapper) catalinaRequest.getMappingData().wrapper);
 
         // Filter trace method
-        if (!connector.getAllowTrace() && Method.TRACE.equals(req.getMethod())) {
-            Wrapper wrapper = request.getWrapper();
+        if (!connector.getAllowTrace() && Method.TRACE.equals(grizzlyRequest.getMethod())) {
+            Wrapper wrapper = catalinaRequest.getWrapper();
             String header = null;
             if (wrapper != null) {
                 String[] methods = wrapper.getServletMethods();
@@ -529,113 +436,86 @@
                     }
                 }
             }
-            res.setStatus(405, "TRACE method is not allowed");
-            res.addHeader("Allow", header);
+            grizzlyResponse.setStatus(405, "TRACE method is not allowed");
+            grizzlyResponse.addHeader("Allow", header);
+
             return false;
         }
 
         // Possible redirect
-        DataChunk redirectPathMB = request.getMappingData().redirectPath;
-        // START SJSAS 6253524
-        // if (!redirectPathMB.isNull()) {
-        // END SJSAS 6253524
-        // START SJSAS 6253524
-        if (!redirectPathMB.isNull()
-            && (!ctx.hasAdHocPaths()
-                || (ctx.getAdHocServletName(((HttpServletRequest)
-                        request.getRequest()).getServletPath()) == null))) {
-        // END SJSAS 6253524
+        DataChunk redirectPathMB = catalinaRequest.getMappingData().redirectPath;
+        if (!redirectPathMB.isNull() && (!catalinaContext.hasAdHocPaths() || (catalinaContext.getAdHocServletName(catalinaRequest.getRequest().getServletPath()) == null))) {
             String redirectPath = redirectPathMB.toString();
-            String query = request.getQueryString();
-            if (request.isRequestedSessionIdFromURL()) {
-                // This is not optimal, but as this is not very common, it
-                // shouldn't matter
-                redirectPath = redirectPath + ";" + ctx.getSessionParameterName() + "="
-                    + request.getRequestedSessionId();
+            String query = catalinaRequest.getQueryString();
+            if (catalinaRequest.isRequestedSessionIdFromURL()) {
+                // This is not optimal, but as this is not very common, it shouldn't matter
+                redirectPath = redirectPath + ";" + catalinaContext.getSessionParameterName() + "=" + catalinaRequest.getRequestedSessionId();
             }
-            // START GlassFish 936
-            redirectPath = response.encode(redirectPath);
-            // END GlassFish 936
+
+            redirectPath = catalinaResponse.encode(redirectPath);
             if (query != null) {
-                // This is not optimal, but as this is not very common, it
-                // shouldn't matter
+                // This is not optimal, but as this is not very common, it shouldn't matter
                 redirectPath = redirectPath + "?" + query;
             }
 
-            // START CR 6590921
-            boolean authPassthroughEnabled =
-                connector.getAuthPassthroughEnabled();
+            boolean authPassthroughEnabled = connector.getAuthPassthroughEnabled();
             ProxyHandler proxyHandler = connector.getProxyHandler();
             if (authPassthroughEnabled && proxyHandler != null) {
-
-                if (proxyHandler.getSSLKeysize(
-                        (HttpServletRequest)request.getRequest()) > 0) {
-                    request.setSecure(true);
+                if (proxyHandler.getSSLKeysize(catalinaRequest.getRequest()) > 0) {
+                    catalinaRequest.setSecure(true);
                 }
             }
-            // END CR 6590921
+
             // Issue a permanent redirect
             // Validating the redirectPath for header injection
             if (InputValidationUtil.validateStringforCRLF(redirectPath)) {
-                response.sendError(403, "Forbidden");
+                catalinaResponse.sendError(403, "Forbidden");
             } else {
-                response.sendRedirect(InputValidationUtil.removeLinearWhiteSpaces(redirectPath),
-                        false);
+                catalinaResponse.sendRedirect(InputValidationUtil.removeLinearWhiteSpaces(redirectPath), false);
             }
 
             return false;
         }
 
         // Parse session Id
-        /* CR 6309511
-        parseSessionCookiesId(req, request);
-         */
-        // START CR 6309511
-        request.parseSessionCookiesId();
-        // END CR 6309511
-
-        // START SJSAS 6346226
-        request.parseJrouteCookie();
-        // END SJSAS 6346226
+        catalinaRequest.parseSessionCookiesId();
+        catalinaRequest.parseJrouteCookie();
 
         return true;
     }
 
-
     /**
      * Normalize URI.
      * <p>
-     * This method normalizes "\", "//", "/./" and "/../". This method will
-     * return false when trying to go above the root, or if the URI contains
-     * a null byte.
+     * This method normalizes "\", "//", "/./" and "/../". This method will return false when trying to go above the root,
+     * or if the URI contains a null byte.
      *
      * @param uriMB URI to be normalized
      */
     public static boolean normalize(MessageBytes uriMB) {
-
         int type = uriMB.getType();
         if (type == MessageBytes.T_CHARS) {
             return normalizeChars(uriMB);
-        } else {
-            return normalizeBytes(uriMB);
         }
+
+        return normalizeBytes(uriMB);
     }
 
-
     private static boolean normalizeBytes(MessageBytes uriMB) {
-
         ByteChunk uriBC = uriMB.getByteChunk();
         byte[] b = uriBC.getBytes();
         int start = uriBC.getStart();
         int end = uriBC.getEnd();
 
         // An empty URL is not acceptable
-        if (start == end)
+        if (start == end) {
             return false;
+        }
 
         // URL * is acceptable
-        if ((end - start == 1) && b[start] == (byte) '*')
-          return true;
+        if ((end - start == 1) && b[start] == (byte) '*') {
+            return true;
+        }
 
         int pos = 0;
         int index = 0;
@@ -676,9 +556,7 @@
         // Note: It is possible to extend the URI by 1 without any side effect
         // as the next character is a non-significant WS.
         if (((end - start) > 2) && (b[end - 1] == (byte) '.')) {
-            if ((b[end - 2] == (byte) '/')
-                || ((b[end - 2] == (byte) '.')
-                    && (b[end - 3] == (byte) '/'))) {
+            if ((b[end - 2] == (byte) '/') || ((b[end - 2] == (byte) '.') && (b[end - 3] == (byte) '/'))) {
                 b[end] = (byte) '/';
                 end++;
             }
@@ -691,10 +569,10 @@
         // Resolve occurrences of "/./" in the normalized path
         while (true) {
             index = uriBC.indexOf("/./", 0, 3, index);
-            if (index < 0)
+            if (index < 0) {
                 break;
-            copyBytes(b, start + index, start + index + 2,
-                      end - start - index - 2);
+            }
+            copyBytes(b, start + index, start + index + 2, end - start - index - 2);
             end = end - 2;
             uriBC.setEnd(end);
         }
@@ -704,19 +582,20 @@
         // Resolve occurrences of "/../" in the normalized path
         while (true) {
             index = uriBC.indexOf("/../", 0, 4, index);
-            if (index < 0)
+            if (index < 0) {
                 break;
+            }
             // Prevent from going outside our context
-            if (index == 0)
+            if (index == 0) {
                 return false;
+            }
             int index2 = -1;
-            for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos --) {
+            for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos--) {
                 if (b[pos] == (byte) '/') {
                     index2 = pos;
                 }
             }
-            copyBytes(b, start + index2, start + index + 3,
-                      end - start - index - 3);
+            copyBytes(b, start + index2, start + index + 3, end - start - index - 3);
             end = end + index2 - index - 3;
             uriBC.setEnd(end);
             index = index2;
@@ -725,20 +604,18 @@
         uriBC.setBytes(b, start, end);
 
         return true;
-
     }
 
-
-    private static boolean normalizeChars(MessageBytes uriMB) {
-
-        CharChunk uriCC = uriMB.getCharChunk();
-        char[] c = uriCC.getChars();
-        int start = uriCC.getStart();
-        int end = uriCC.getEnd();
+    private static boolean normalizeChars(MessageBytes uriMessageBytes) {
+        CharChunk uriCharChunk = uriMessageBytes.getCharChunk();
+        char[] c = uriCharChunk.getChars();
+        int start = uriCharChunk.getStart();
+        int end = uriCharChunk.getEnd();
 
         // URL * is acceptable
-        if ((end - start == 1) && c[start] == (char) '*')
-          return true;
+        if ((end - start == 1) && c[start] == '*') {
+            return true;
+        }
 
         int pos = 0;
         int index = 0;
@@ -746,9 +623,9 @@
         // Replace '\' with '/'
         // Check for null char
         for (pos = start; pos < end; pos++) {
-            if (c[pos] == (char) '\\') {
+            if (c[pos] == '\\') {
                 if (ALLOW_BACKSLASH) {
-                    c[pos] = (char) '/';
+                    c[pos] = '/';
                 } else {
                     return false;
                 }
@@ -759,15 +636,15 @@
         }
 
         // The URL must start with '/'
-        if (c[start] != (char) '/') {
+        if (c[start] != '/') {
             return false;
         }
 
         // Replace "//" with "/"
         if (COLLAPSE_ADJACENT_SLASHES) {
             for (pos = start; pos < (end - 1); pos++) {
-                if (c[pos] == (char) '/') {
-                    while ((pos + 1 < end) && (c[pos + 1] == (char) '/')) {
+                if (c[pos] == '/') {
+                    while ((pos + 1 < end) && (c[pos + 1] == '/')) {
                         copyChars(c, pos, pos + 1, end - pos - 1);
                         end--;
                     }
@@ -778,66 +655,61 @@
         // If the URI ends with "/." or "/..", then we append an extra "/"
         // Note: It is possible to extend the URI by 1 without any side effect
         // as the next character is a non-significant WS.
-        if (((end - start) > 2) && (c[end - 1] == (char) '.')) {
-            if ((c[end - 2] == (char) '/')
-                || ((c[end - 2] == (char) '.')
-                    && (c[end - 3] == (char) '/'))) {
-                c[end] = (char) '/';
+        if (((end - start) > 2) && (c[end - 1] == '.')) {
+            if ((c[end - 2] == '/') || ((c[end - 2] == '.') && (c[end - 3] == '/'))) {
+                c[end] = '/';
                 end++;
             }
         }
 
-        uriCC.setEnd(end);
+        uriCharChunk.setEnd(end);
 
         index = 0;
 
         // Resolve occurrences of "/./" in the normalized path
         while (true) {
-            index = uriCC.indexOf("/./", 0, 3, index);
-            if (index < 0)
+            index = uriCharChunk.indexOf("/./", 0, 3, index);
+            if (index < 0) {
                 break;
-            copyChars(c, start + index, start + index + 2,
-                      end - start - index - 2);
+            }
+            copyChars(c, start + index, start + index + 2, end - start - index - 2);
             end = end - 2;
-            uriCC.setEnd(end);
+            uriCharChunk.setEnd(end);
         }
 
         index = 0;
 
         // Resolve occurrences of "/../" in the normalized path
         while (true) {
-            index = uriCC.indexOf("/../", 0, 4, index);
-            if (index < 0)
+            index = uriCharChunk.indexOf("/../", 0, 4, index);
+            if (index < 0) {
                 break;
+            }
             // Prevent from going outside our context
-            if (index == 0)
+            if (index == 0) {
                 return false;
+            }
             int index2 = -1;
-            for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos --) {
-                if (c[pos] == (char) '/') {
+            for (pos = start + index - 1; (pos >= 0) && (index2 < 0); pos--) {
+                if (c[pos] == '/') {
                     index2 = pos;
                 }
             }
-            copyChars(c, start + index2, start + index + 3,
-                      end - start - index - 3);
+            copyChars(c, start + index2, start + index + 3, end - start - index - 3);
             end = end + index2 - index - 3;
-            uriCC.setEnd(end);
+            uriCharChunk.setEnd(end);
             index = index2;
         }
 
-        uriCC.setChars(c, start, end);
+        uriCharChunk.setChars(c, start, end);
 
         return true;
-
     }
 
-
     // ------------------------------------------------------ Protected Methods
 
-
     /**
-     * Copy an array of bytes to a different position. Used during
-     * normalization.
+     * Copy an array of bytes to a different position. Used during normalization.
      */
     protected static void copyBytes(byte[] b, int dest, int src, int len) {
         for (int pos = 0; pos < len; pos++) {
@@ -845,10 +717,8 @@
         }
     }
 
-
     /**
-     * Copy an array of chars to a different position. Used during
-     * normalization.
+     * Copy an array of chars to a different position. Used during normalization.
      */
     private static void copyChars(char[] c, int dest, int src, int len) {
         for (int pos = 0; pos < len; pos++) {
@@ -856,17 +726,15 @@
         }
     }
 
-
     /**
      * Log a message on the Logger associated with our Container (if any)
      *
      * @param message Message to be logged
      */
     protected void log(String message) {
-        log.log(Level.INFO, message);
+        log.log(INFO, message);
     }
 
-
     /**
      * Log a message on the Logger associated with our Container (if any)
      *
@@ -874,58 +742,25 @@
      * @param throwable Associated exception
      */
     protected void log(String message, Throwable throwable) {
-        log.log(Level.SEVERE, message, throwable);
+        log.log(SEVERE, message, throwable);
     }
 
-
-     /**
-      * Character conversion of the a US-ASCII MessageBytes.
-      */
-    /* CR 6309511
-     protected void convertMB(MessageBytes mb) {
-
-        // This is of course only meaningful for bytes
-        if (mb.getType() != MessageBytes.T_BYTES)
-            return;
-
-        ByteChunk bc = mb.getByteChunk();
-        CharChunk cc = mb.getCharChunk();
-        cc.allocate(bc.getLength(), -1);
-
-        // Default encoding: fast conversion
-        byte[] bbuf = bc.getBuffer();
-        char[] cbuf = cc.getBuffer();
-        int start = bc.getStart();
-        for (int i = 0; i < bc.getLength(); i++) {
-            cbuf[i] = (char) (bbuf[i + start] & 0xff);
-        }
-        mb.setChars(cbuf, 0, bc.getLength());
-
-     }
-     */
-
-
-    // START SJSAS 6349248
     /**
-     * Notify all container event listeners that a particular event has
-     * occurred for this Adapter.  The default implementation performs
-     * this notification synchronously using the calling thread.
+     * Notify all container event listeners that a particular event has occurred for this Adapter. The default
+     * implementation performs this notification synchronously using the calling thread.
      *
      * @param type Event type
      * @param data Event data
      */
     public void fireAdapterEvent(String type, Object data) {
-        if ( connector != null && connector.getContainer() != null) {
-            try{
-                ((ContainerBase)connector.getContainer())
-                    .fireContainerEvent(type,data);
-            } catch (Throwable t){
-                log.log(Level.SEVERE, LogFacade.REQUEST_PROCESSING_EXCEPTION, t);
+        if (connector != null && connector.getContainer() != null) {
+            try {
+                ((ContainerBase) connector.getContainer()).fireContainerEvent(type, data);
+            } catch (Throwable t) {
+                log.log(SEVERE, REQUEST_PROCESSING_EXCEPTION, t);
             }
         }
     }
-    // END SJSAS 6349248
-
 
     /**
      * Return true when an instance is executed the same way it does in Tomcat.
@@ -934,18 +769,15 @@
         return compatWithTomcat;
     }
 
-
     /**
-     * <tt>true</tt> if this class needs to be compatible with Tomcat
-     * Adapter class. Since Tomcat Adapter implementation doesn't support
-     * the afterService method, the afterService method must be invoked
-     * inside the service method.
+     * <tt>true</tt> if this class needs to be compatible with Tomcat Adapter class. Since Tomcat Adapter implementation
+     * doesn't support the afterService method, the afterService method must be invoked inside the service method.
      */
     public void setCompatWithTomcat(boolean compatWithTomcat) {
         this.compatWithTomcat = compatWithTomcat;
 
         // Add server header
-        if (compatWithTomcat){
+        if (compatWithTomcat) {
             serverName = "Apache/" + serverName;
         } else {
             // Recalculate.
@@ -953,7 +785,6 @@
         }
     }
 
-
     /**
      * Gets the port of this CoyoteAdapter.
      *
@@ -964,31 +795,30 @@
     }
 
     /**
-     * AfterServiceListener, which is responsible for recycle catalina request and response
-     * objects.
+     * AfterServiceListener, which is responsible for recycle catalina request and response objects.
      */
     static final class CatalinaAfterServiceListener implements AfterServiceListener {
 
         @Override
-        public void onAfterService(final org.glassfish.grizzly.http.server.Request request) {
-            final Request servletRequest = request.getNote(CATALINA_REQUEST_NOTE);
-            final Response servletResponse = request.getNote(CATALINA_RESPONSE_NOTE);
+        public void onAfterService(final org.glassfish.grizzly.http.server.Request grizzlyRequest) {
+            final Request catalinaRequest = grizzlyRequest.getNote(CATALINA_REQUEST_NOTE);
+            final Response catalinaResponse = grizzlyRequest.getNote(CATALINA_RESPONSE_NOTE);
 
-            if (servletRequest != null) {
+            if (catalinaRequest != null) {
                 try {
-                    if (!servletRequest.isUpgrade()) {
-                        servletResponse.finishResponse();
+                    if (!catalinaRequest.isUpgrade()) {
+                        catalinaResponse.finishResponse();
                     } else {
-                        servletResponse.setUpgrade(servletRequest.isUpgrade());
+                        catalinaResponse.setUpgrade(catalinaRequest.isUpgrade());
                     }
                 } catch (Exception e) {
-                    log.log(Level.SEVERE, LogFacade.REQUEST_PROCESSING_EXCEPTION, e);
+                    log.log(SEVERE, REQUEST_PROCESSING_EXCEPTION, e);
                 } finally {
                     try {
-                        servletRequest.unlockSession();
+                        catalinaRequest.unlockSession();
                     } finally {
-                        servletRequest.recycle();
-                        servletResponse.recycle();
+                        catalinaRequest.recycle();
+                        catalinaResponse.recycle();
                     }
                 }
             }
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Request.java b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Request.java
index c99c443..4ede460 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Request.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/connector/Request.java
@@ -349,7 +349,7 @@
     protected String requestedSessionCookiePath;
 
     // Temporary holder for URI params from which session id is parsed
-    protected CharChunk uriParamsCC = new CharChunk();
+    protected CharChunk uriParamsCharChunk = new CharChunk();
 
     /**
      * Was the requested session ID received in a URL?
@@ -424,9 +424,9 @@
     private String requestURI;
 
     /**
-     * Coyote request.
+     * Grizzly request.
      */
-    protected org.glassfish.grizzly.http.server.Request coyoteRequest;
+    protected org.glassfish.grizzly.http.server.Request grizzlyRequest;
 
     /**
      * The facade associated with this request.
@@ -532,8 +532,8 @@
      *
      * @param grizzlyRequest The Coyote request
      */
-    public void setCoyoteRequest(org.glassfish.grizzly.http.server.Request grizzlyRequest) {
-        this.coyoteRequest = grizzlyRequest;
+    public void setGrizzlyRequest(org.glassfish.grizzly.http.server.Request grizzlyRequest) {
+        this.grizzlyRequest = grizzlyRequest;
         inputBuffer.setRequest(grizzlyRequest);
         inputBuffer.setRequest(this);
     }
@@ -541,8 +541,8 @@
     /**
      * Get the Coyote request.
      */
-    public org.glassfish.grizzly.http.server.Request getCoyoteRequest() {
-        return this.coyoteRequest;
+    public org.glassfish.grizzly.http.server.Request getGrizzlyRequest() {
+        return this.grizzlyRequest;
     }
 
     /**
@@ -610,7 +610,7 @@
         requestedSessionId = null;
         requestedSessionCookiePath = null;
         requestedSessionURL = false;
-        uriParamsCC.recycle();
+        uriParamsCharChunk.recycle();
         sessionTracker.reset();
 
         /*
@@ -689,7 +689,7 @@
      */
     @Override
     public String getAuthorization() {
-        return coyoteRequest.getHeader(AUTHORIZATION_HEADER);
+        return grizzlyRequest.getHeader(AUTHORIZATION_HEADER);
     }
 
     /**
@@ -1064,7 +1064,7 @@
      */
     @Override
     public void setContentLength(int length) {
-        coyoteRequest.getRequest().setContentLength(length);
+        grizzlyRequest.getRequest().setContentLength(length);
     }
 
     /**
@@ -1124,7 +1124,7 @@
      */
     @Override
     public void setServerName(String name) {
-        coyoteRequest.setServerName(name);
+        grizzlyRequest.setServerName(name);
     }
 
     /**
@@ -1134,7 +1134,7 @@
      */
     @Override
     public void setServerPort(int port) {
-        coyoteRequest.setServerPort(port);
+        grizzlyRequest.setServerPort(port);
     }
 
     /**
@@ -1180,20 +1180,20 @@
             return attribute;
         }
 
-        attribute = coyoteRequest.getAttribute(name);
+        attribute = grizzlyRequest.getAttribute(name);
         if (attribute != null) {
             return attribute;
         }
 
         if (Globals.SSL_CERTIFICATE_ATTR.equals(name)) {
             // @TODO Implement SSL rehandshake
-            RequestUtils.populateCertificateAttribute(coyoteRequest);
+            RequestUtils.populateCertificateAttribute(grizzlyRequest);
             attribute = getAttribute(CERTIFICATES_ATTR);
             if (attribute != null) {
                 attributes.put(name, attribute);
             }
         } else if (isSSLAttribute(name)) {
-            RequestUtils.populateSSLAttributes(coyoteRequest);
+            RequestUtils.populateSSLAttributes(grizzlyRequest);
             attribute = attributes.get(name);
         }
 
@@ -1226,7 +1226,7 @@
      */
     @Override
     public String getCharacterEncoding() {
-        return coyoteRequest.getCharacterEncoding();
+        return grizzlyRequest.getCharacterEncoding();
     }
 
     /**
@@ -1234,7 +1234,7 @@
      */
     @Override
     public int getContentLength() {
-        return coyoteRequest.getContentLength();
+        return grizzlyRequest.getContentLength();
     }
 
     /**
@@ -1242,7 +1242,7 @@
      */
     @Override
     public long getContentLengthLong() {
-        return coyoteRequest.getContentLengthLong();
+        return grizzlyRequest.getContentLengthLong();
     }
 
     /**
@@ -1250,7 +1250,7 @@
      */
     @Override
     public String getContentType() {
-        return coyoteRequest.getContentType();
+        return grizzlyRequest.getContentType();
     }
 
     /**
@@ -1281,7 +1281,7 @@
      */
     @Override
     public Locale getLocale() {
-        return coyoteRequest.getLocale();
+        return grizzlyRequest.getLocale();
     }
 
     /**
@@ -1291,7 +1291,7 @@
      */
     @Override
     public Enumeration<Locale> getLocales() {
-        return new Enumerator<>(coyoteRequest.getLocales());
+        return new Enumerator<>(grizzlyRequest.getLocales());
     }
 
     private void processParameters() {
@@ -1320,7 +1320,7 @@
     public String getParameter(String name) {
         processParameters();
 
-        return coyoteRequest.getParameter(name);
+        return grizzlyRequest.getParameter(name);
     }
 
     /**
@@ -1354,7 +1354,7 @@
     public Enumeration<String> getParameterNames() {
         processParameters();
 
-        return new Enumerator<>(coyoteRequest.getParameterNames());
+        return new Enumerator<>(grizzlyRequest.getParameterNames());
     }
 
     /**
@@ -1366,7 +1366,7 @@
     public String[] getParameterValues(String name) {
         processParameters();
 
-        return coyoteRequest.getParameterValues(name);
+        return grizzlyRequest.getParameterValues(name);
     }
 
     /**
@@ -1374,7 +1374,7 @@
      */
     @Override
     public String getProtocol() {
-        return coyoteRequest.getProtocol().getProtocolString();
+        return grizzlyRequest.getProtocol().getProtocolString();
     }
 
     /**
@@ -1425,7 +1425,7 @@
                 InetAddress inet = socket.getInetAddress();
                 remoteAddr = inet.getHostAddress();
             } else {
-                remoteAddr = coyoteRequest.getRemoteAddr();
+                remoteAddr = grizzlyRequest.getRemoteAddr();
             }
         }
 
@@ -1456,7 +1456,7 @@
                 InetAddress inet = socket.getInetAddress();
                 remoteHost = inet.getHostName();
             } else {
-                remoteHost = coyoteRequest.getRemoteHost();
+                remoteHost = grizzlyRequest.getRemoteHost();
             }
         }
 
@@ -1472,7 +1472,7 @@
             if (socket != null) {
                 remotePort = socket.getPort();
             } else {
-                remotePort = coyoteRequest.getRemotePort();
+                remotePort = grizzlyRequest.getRemotePort();
             }
         }
 
@@ -1489,7 +1489,7 @@
                 InetAddress inet = socket.getLocalAddress();
                 localName = inet.getHostName();
             } else {
-                localName = coyoteRequest.getLocalName();
+                localName = grizzlyRequest.getLocalName();
             }
         }
 
@@ -1506,7 +1506,7 @@
                 InetAddress inet = socket.getLocalAddress();
                 localAddr = inet.getHostAddress();
             } else {
-                localAddr = coyoteRequest.getLocalAddr();
+                localAddr = grizzlyRequest.getLocalAddr();
             }
         }
 
@@ -1522,7 +1522,7 @@
             if (socket != null) {
                 localPort = socket.getLocalPort();
             } else {
-                localPort = coyoteRequest.getLocalPort();
+                localPort = grizzlyRequest.getLocalPort();
             }
         }
 
@@ -1589,7 +1589,7 @@
             }
         }
 
-        return coyoteRequest.getScheme();
+        return grizzlyRequest.getScheme();
     }
 
     /**
@@ -1597,7 +1597,7 @@
      */
     @Override
     public String getServerName() {
-        return coyoteRequest.getServerName();
+        return grizzlyRequest.getServerName();
     }
 
     /**
@@ -1613,7 +1613,7 @@
             }
         }
 
-        return coyoteRequest.getServerPort();
+        return grizzlyRequest.getServerPort();
     }
 
     /**
@@ -1719,7 +1719,7 @@
 
         // Pass special attributes to the grizzly layer
         if (name.startsWith("grizzly.")) {
-            coyoteRequest.setAttribute(name, value);
+            grizzlyRequest.setAttribute(name, value);
         }
 
         // Notify interested application event listeners
@@ -1799,7 +1799,7 @@
         }
 
         // Save the validated encoding
-        coyoteRequest.setCharacterEncoding(enc);
+        grizzlyRequest.setCharacterEncoding(enc);
     }
 
     /**
@@ -1954,7 +1954,7 @@
      */
     @Override
     public void addHeader(String name, String value) {
-        coyoteRequest.getRequest().getHeaders().addValue(name).setString(value);
+        grizzlyRequest.getRequest().getHeaders().addValue(name).setString(value);
     }
 
     /**
@@ -1977,7 +1977,7 @@
      */
     @Override
     public void addParameter(String name, String values[]) {
-        coyoteRequest.addParameter(name, values);
+        grizzlyRequest.addParameter(name, values);
     }
 
     /**
@@ -1994,7 +1994,7 @@
      */
     @Override
     public void clearHeaders() {
-        coyoteRequest.getRequest().getHeaders().recycle();
+        grizzlyRequest.getRequest().getHeaders().recycle();
     }
 
     /**
@@ -2010,8 +2010,8 @@
      */
     @Override
     public void clearParameters() {
-        coyoteRequest.getParameters().recycle();
-        coyoteRequest.getParameters().setQueryStringEncoding(Charsets.lookupCharset(getConnector().getURIEncoding()));
+        grizzlyRequest.getParameters().recycle();
+        grizzlyRequest.getParameters().setQueryStringEncoding(Charsets.lookupCharset(getConnector().getURIEncoding()));
     }
 
     @Override
@@ -2020,7 +2020,7 @@
             return;
         }
 
-        coyoteRequest.replayPayload(Buffers.wrap(coyoteRequest.getContext().getMemoryManager(), payloadByteArray));
+        grizzlyRequest.replayPayload(Buffers.wrap(grizzlyRequest.getContext().getMemoryManager(), payloadByteArray));
     }
 
     /**
@@ -2044,7 +2044,7 @@
      */
     @Override
     public void setMethod(String method) {
-        coyoteRequest.setMethod(method);
+        grizzlyRequest.setMethod(method);
     }
 
     /**
@@ -2057,7 +2057,7 @@
      */
     @Override
     public void setQueryString(String query) {
-        coyoteRequest.setQueryString(query);
+        grizzlyRequest.setQueryString(query);
     }
 
     /**
@@ -2141,7 +2141,7 @@
      */
     @Override
     public void setRequestURI(String uri) {
-        coyoteRequest.setRequestURI(uri);
+        grizzlyRequest.setRequestURI(uri);
     }
 
     /**
@@ -2163,9 +2163,9 @@
     public String getDecodedRequestURI(boolean maskDefaultContextMapping) {
         try {
             if (maskDefaultContextMapping || !isDefaultContext) {
-                return coyoteRequest.getDecodedRequestURI();
+                return grizzlyRequest.getDecodedRequestURI();
             } else {
-                return getContextPath() + coyoteRequest.getDecodedRequestURI();
+                return getContextPath() + grizzlyRequest.getDecodedRequestURI();
             }
         } catch (CharConversionException e) {
             throw new RuntimeException(e.getMessage(), e);
@@ -2296,7 +2296,7 @@
      */
     @Override
     public String getHeader(String name) {
-        return coyoteRequest.getHeader(name);
+        return grizzlyRequest.getHeader(name);
     }
 
     /**
@@ -2306,7 +2306,7 @@
      */
     @Override
     public Enumeration<String> getHeaders(String name) {
-        return new Enumerator<>(coyoteRequest.getHeaders(name).iterator());
+        return new Enumerator<>(grizzlyRequest.getHeaders(name).iterator());
     }
 
     /**
@@ -2314,7 +2314,7 @@
      */
     @Override
     public Enumeration<String> getHeaderNames() {
-        return new Enumerator<>(coyoteRequest.getHeaderNames().iterator());
+        return new Enumerator<>(grizzlyRequest.getHeaderNames().iterator());
     }
 
     /**
@@ -2336,12 +2336,12 @@
 
     @Override
     public Map<String, String> getTrailerFields() {
-        return coyoteRequest.getTrailers();
+        return grizzlyRequest.getTrailers();
     }
 
     @Override
     public boolean isTrailerFieldsReady() {
-        return coyoteRequest.areTrailersAvailable();
+        return grizzlyRequest.areTrailersAvailable();
     }
 
     /**
@@ -2349,7 +2349,7 @@
      */
     @Override
     public String getMethod() {
-        return coyoteRequest.getMethod().getMethodString();
+        return grizzlyRequest.getMethod().getMethodString();
     }
 
     /**
@@ -2379,8 +2379,8 @@
     @Override
     public PushBuilder newPushBuilder() {
         Http2Stream http2Stream = null;
-        if (coyoteRequest != null) {
-            http2Stream = (Http2Stream) coyoteRequest.getAttribute(Http2Stream.HTTP2_STREAM_ATTRIBUTE);
+        if (grizzlyRequest != null) {
+            http2Stream = (Http2Stream) grizzlyRequest.getAttribute(Http2Stream.HTTP2_STREAM_ATTRIBUTE);
         }
 
         if (http2Stream != null && http2Stream.isPushEnabled()) {
@@ -2395,7 +2395,7 @@
      */
     @Override
     public String getQueryString() {
-        String queryString = coyoteRequest.getQueryString();
+        String queryString = grizzlyRequest.getQueryString();
 
         if (queryString == null || "".equals(queryString)) {
             return null;
@@ -2450,14 +2450,14 @@
      */
     public String getRequestURI(boolean maskDefaultContextMapping) {
         if (maskDefaultContextMapping) {
-            return coyoteRequest.getRequestURI();
+            return grizzlyRequest.getRequestURI();
         }
 
         if (requestURI == null) {
             if (isDefaultContext) {
-                requestURI = getContextPath() + coyoteRequest.getRequestURI();
+                requestURI = getContextPath() + grizzlyRequest.getRequestURI();
             } else {
-                requestURI = coyoteRequest.getRequestURI();
+                requestURI = grizzlyRequest.getRequestURI();
             }
         }
 
@@ -2764,7 +2764,7 @@
             throw new ServletException(t);
         }
         httpUpgradeHandler = handler;
-        coyoteRequest.getResponse().suspend();
+        grizzlyRequest.getResponse().suspend();
         return handler;
     }
 
@@ -2958,7 +2958,7 @@
     protected void parseCookies() {
         cookiesParsed = true;
 
-        org.glassfish.grizzly.http.Cookie[] serverCookies = coyoteRequest.getCookies();
+        org.glassfish.grizzly.http.Cookie[] serverCookies = grizzlyRequest.getCookies();
         int count = serverCookies.length;
         if (count <= 0) {
             return;
@@ -3033,7 +3033,7 @@
      * Read post body in an array.
      */
     protected int readPostBody(byte body[], int len) throws IOException {
-        Buffer b = coyoteRequest.getPostBody(len).duplicate();
+        Buffer b = grizzlyRequest.getPostBody(len).duplicate();
         final int length = b.limit() - b.position();
         b.get(body, b.position(), length);
         return length;
@@ -3064,18 +3064,18 @@
      */
     protected void obtainSessionId() {
         setRequestedSessionURL(true);
-        setJrouteId(coyoteRequest.getJrouteId());
-        setRequestedSessionId(coyoteRequest.getRequestedSessionId());
+        setJrouteId(grizzlyRequest.getJrouteId());
+        setRequestedSessionId(grizzlyRequest.getRequestedSessionId());
     }
 
     /**
      * Parse session id in URL.
      */
-    protected void parseSessionId(String sessionParameterName, CharChunk uriBB) {
+    protected void parseSessionId(String sessionParameterName, CharChunk uriCharChunk) {
 
         // Parse session ID, and extract it from the decoded request URI
         String sessionParam = ";" + sessionParameterName + "=";
-        String sessionId = parseParameterFromRequestURI(uriBB, sessionParam);
+        String sessionId = parseParameterFromRequestURI(uriCharChunk, sessionParam);
 
         if (sessionId != null) {
             int jrouteIndex = sessionId.lastIndexOf(':');
@@ -3093,7 +3093,7 @@
             /*
              * Parse the session id from the encoded URI only if the encoded URI is not null, to allow for lazy evaluation
              */
-            if (coyoteRequest.getRequestURI() != null) {
+            if (grizzlyRequest.getRequestURI() != null) {
                 removeParameterFromRequestURI(sessionParam);
             }
 
@@ -3153,21 +3153,21 @@
      * @param parameter of the form ";" + parameterName + "="
      * @return parameterValue
      */
-    private String parseParameterFromRequestURI(CharChunk uriCC, String parameter) {
+    private String parseParameterFromRequestURI(CharChunk uriCharChunk, String parameter) {
         String parameterValue = null;
 
-        int semicolon = uriCC.indexOf(parameter, 0, parameter.length(), 0);
+        int semicolon = uriCharChunk.indexOf(parameter, 0, parameter.length(), 0);
         if (semicolon >= 0) {
 
-            int start = uriCC.getStart();
-            int end = uriCC.getEnd();
+            int start = uriCharChunk.getStart();
+            int end = uriCharChunk.getEnd();
 
             int parameterStart = start + semicolon + parameter.length();
-            int semicolon2 = uriCC.indexOf(';', semicolon + parameter.length());
+            int semicolon2 = uriCharChunk.indexOf(';', semicolon + parameter.length());
             if (semicolon2 >= 0) {
-                parameterValue = new String(uriCC.getBuffer(), parameterStart, semicolon2 - semicolon - parameter.length());
+                parameterValue = new String(uriCharChunk.getBuffer(), parameterStart, semicolon2 - semicolon - parameter.length());
             } else {
-                parameterValue = new String(uriCC.getBuffer(), parameterStart, end - parameterStart);
+                parameterValue = new String(uriCharChunk.getBuffer(), parameterStart, end - parameterStart);
             }
 
         }
@@ -3183,22 +3183,22 @@
     private void removeParameterFromRequestURI(String parameter) {
         int semicolon, semicolon2;
 
-        final DataChunk uriBC = coyoteRequest.getRequest().getRequestURIRef().getRequestURIBC();
+        final DataChunk uriDataChunk = grizzlyRequest.getRequest().getRequestURIRef().getRequestURIBC();
 
-        semicolon = uriBC.indexOf(parameter, 0);
+        semicolon = uriDataChunk.indexOf(parameter, 0);
 
         if (semicolon > 0) {
-            semicolon2 = uriBC.indexOf(';', semicolon + parameter.length());
+            semicolon2 = uriDataChunk.indexOf(';', semicolon + parameter.length());
 
             final int end;
             if (semicolon2 >= 0) {
                 end = semicolon2;
-                uriBC.notifyDirectUpdate();
+                uriDataChunk.notifyDirectUpdate();
             } else {
-                end = uriBC.getLength();
+                end = uriDataChunk.getLength();
             }
 
-            uriBC.delete(semicolon, end);
+            uriDataChunk.delete(semicolon, end);
         }
     }
 
@@ -3231,7 +3231,7 @@
      * Parses the value of the JROUTE cookie, if present.
      */
     void parseJrouteCookie() {
-        org.glassfish.grizzly.http.Cookie[] serverCookies = coyoteRequest.getCookies();
+        org.glassfish.grizzly.http.Cookie[] serverCookies = grizzlyRequest.getCookies();
         int count = serverCookies.length;
         if (count <= 0) {
             return;
@@ -3281,7 +3281,7 @@
         }
 
         // Parse session id from cookies
-        org.glassfish.grizzly.http.Cookie[] serverCookies = coyoteRequest.getCookies();
+        org.glassfish.grizzly.http.Cookie[] serverCookies = grizzlyRequest.getCookies();
         int count = serverCookies.length;
         if (count <= 0) {
             return;
@@ -3299,23 +3299,18 @@
                 if (!isRequestedSessionIdFromCookie()) {
                     // Accept only the first session id cookie
                     setRequestedSessionId(scookie.getValue());
-                    // TODO: Pass cookie path into
-                    // getSessionVersionFromCookie()
-                    String sessionVersionString = getSessionVersionFromCookie();
-                    parseSessionVersionString(sessionVersionString);
+                    // TODO: Pass cookie path into getSessionVersionFromCookie()
+                    parseSessionVersionString(getSessionVersionFromCookie());
                     setRequestedSessionCookie(true);
-                    // TBD: ServerCookie#getSecure currently always returns
-                    // false.
+                    // TBD: ServerCookie#getSecure currently always returns false.
                     setRequestedSessionIdFromSecureCookie(scookie.isSecure());
                     setRequestedSessionURL(false);
                 } else {
                     if (!isRequestedSessionIdValid()) {
                         // Replace the session id until one is valid
                         setRequestedSessionId(scookie.getValue());
-                        // TODO: Pass cookie path into
-                        // getSessionVersionFromCookie()
-                        String sessionVersionString = getSessionVersionFromCookie();
-                        parseSessionVersionString(sessionVersionString);
+                        // TODO: Pass cookie path into getSessionVersionFromCookie()
+                        parseSessionVersionString(getSessionVersionFromCookie());
                     }
                 }
             }
@@ -3332,7 +3327,7 @@
             return null;
         }
 
-        org.glassfish.grizzly.http.Cookie[] serverCookies = coyoteRequest.getCookies();
+        org.glassfish.grizzly.http.Cookie[] serverCookies = grizzlyRequest.getCookies();
         int count = serverCookies.length;
         if (count <= 0) {
             return null;
@@ -3352,7 +3347,7 @@
      * @return temporary holder for URI params from which session id is parsed
      */
     CharChunk getURIParams() {
-        return uriParamsCC;
+        return uriParamsCharChunk;
     }
 
     /**
@@ -3483,7 +3478,7 @@
                 }
             };
 
-            coyoteRequest.getResponse().suspend(-1, TimeUnit.MILLISECONDS, requestCompletionHandler, timeoutHandler);
+            grizzlyRequest.getResponse().suspend(-1, TimeUnit.MILLISECONDS, requestCompletionHandler, timeoutHandler);
             asyncStartedThread = Thread.currentThread();
         }
 
@@ -3516,7 +3511,7 @@
     }
 
     void setAsyncTimeout(long timeout) {
-        coyoteRequest.getResponse().getSuspendContext().setTimeout(timeout, TimeUnit.MILLISECONDS);
+        grizzlyRequest.getResponse().getSuspendContext().setTimeout(timeout, TimeUnit.MILLISECONDS);
 
     }
 
@@ -3548,12 +3543,12 @@
 
         if (asyncStartedThread != Thread.currentThread() || !asyncContext.isOkToConfigure()) {
             // it's not safe to just mark response as resumed
-            coyoteRequest.getResponse().resume();
+            grizzlyRequest.getResponse().resume();
         } else {
             // This code is called if we startAsync and complete in the service() thread.
             // So instead of resuming the suspendedContext (which will finish the response processing),
             // we just have to mark the context as resumed like it has never been suspended.
-            final SuspendedContextImpl suspendContext = (SuspendedContextImpl) coyoteRequest.getResponse().getSuspendContext();
+            final SuspendedContextImpl suspendContext = (SuspendedContextImpl) grizzlyRequest.getResponse().getSuspendContext();
 
             suspendContext.markResumed();
             suspendContext.getSuspendStatus().reset();
@@ -3587,21 +3582,21 @@
             asyncContextImpl.setOkToConfigure(false);
 
             if (asyncStarted.get()) {
-                coyoteRequest.getResponse().getSuspendContext().setTimeout(asyncContextImpl.getTimeout(), TimeUnit.MILLISECONDS);
+                grizzlyRequest.getResponse().getSuspendContext().setTimeout(asyncContextImpl.getTimeout(), TimeUnit.MILLISECONDS);
             }
 
             asyncContextImpl.onExitService();
         }
         afterService = true;
         if (resume) {
-            coyoteRequest.getResponse().resume();
+            grizzlyRequest.getResponse().resume();
         }
 
     }
 
     void resumeAfterService() {
         if (afterService) {
-            coyoteRequest.getResponse().resume();
+            grizzlyRequest.getResponse().resume();
         } else {
             resume = true;
         }
@@ -3708,20 +3703,20 @@
     }
 
     private void populateSSLAttributes() {
-        RequestUtils.populateSSLAttributes(coyoteRequest);
-        Object attr = coyoteRequest.getAttribute(CERTIFICATES_ATTR);
+        RequestUtils.populateSSLAttributes(grizzlyRequest);
+        Object attr = grizzlyRequest.getAttribute(CERTIFICATES_ATTR);
         if (attr != null) {
             attributes.put(CERTIFICATES_ATTR, attr);
         }
-        attr = coyoteRequest.getAttribute(CIPHER_SUITE_ATTR);
+        attr = grizzlyRequest.getAttribute(CIPHER_SUITE_ATTR);
         if (attr != null) {
             attributes.put(CIPHER_SUITE_ATTR, attr);
         }
-        attr = coyoteRequest.getAttribute(KEY_SIZE_ATTR);
+        attr = grizzlyRequest.getAttribute(KEY_SIZE_ATTR);
         if (attr != null) {
             attributes.put(KEY_SIZE_ATTR, attr);
         }
-        attr = coyoteRequest.getAttribute(SSL_SESSION_ID_ATTR);
+        attr = grizzlyRequest.getAttribute(SSL_SESSION_ID_ATTR);
         if (attr != null) {
             attributes.put(SSL_SESSION_ID_ATTR, attr);
         }
diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ApplicationPushBuilder.java b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ApplicationPushBuilder.java
index ce8429f..b8c6d96 100644
--- a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ApplicationPushBuilder.java
+++ b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ApplicationPushBuilder.java
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
  * Copyright (c) 2017-2018 Oracle and/or its affiliates. All rights reserved.
  * Copyright 2004 The Apache Software Foundation
  *
@@ -104,7 +105,7 @@
         }
         if (current instanceof Request) {
             catalinaRequest = ((Request) current);
-            coyoteRequest = catalinaRequest.getCoyoteRequest();
+            coyoteRequest = catalinaRequest.getGrizzlyRequest();
         } else {
             String msg = MessageFormat.format(
                     rb.getString(LogFacade.NO_PUSH_COYOTE_REQUEST_EXCEPTION), current.getClass().getName());
diff --git a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/VirtualServer.java b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/VirtualServer.java
index 76d61c4..1c9e96b 100644
--- a/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/VirtualServer.java
+++ b/appserver/web/web-glue/src/main/java/com/sun/enterprise/web/VirtualServer.java
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2022, 2022 Contributors to the Eclipse Foundation.
  * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
@@ -16,6 +17,123 @@
 
 package com.sun.enterprise.web;
 
+import static com.sun.enterprise.web.Constants.DEFAULT_WEB_MODULE_NAME;
+import static com.sun.enterprise.web.Constants.ERROR_REPORT_VALVE;
+import static java.util.logging.Level.FINE;
+import static java.util.logging.Level.SEVERE;
+import static java.util.logging.Level.WARNING;
+import static org.glassfish.api.web.Constants.ADMIN_VS;
+import static org.glassfish.web.LogFacade.ALLOW_ACCESS;
+import static org.glassfish.web.LogFacade.CODE_FILTERS_NULL;
+import static org.glassfish.web.LogFacade.DENY_ACCESS;
+import static org.glassfish.web.LogFacade.ENABLE_SSO;
+import static org.glassfish.web.LogFacade.IGNORE_INVALID_REALM;
+import static org.glassfish.web.LogFacade.INVALID_AUTH_REALM;
+import static org.glassfish.web.LogFacade.INVALID_LISTENER_VIRTUAL_SERVER;
+import static org.glassfish.web.LogFacade.MODIFYING_WEB_XML;
+import static org.glassfish.web.LogFacade.NOT_A_VALVE;
+import static org.glassfish.web.LogFacade.NULL_VIRTUAL_SERVER_PROPERTY;
+import static org.glassfish.web.LogFacade.REDIRECT_BOTH_URL_AND_URL_PREFIX;
+import static org.glassfish.web.LogFacade.REDIRECT_MISSING_URL_OR_URL_PREFIX;
+import static org.glassfish.web.LogFacade.REDIRECT_MULTIPLE_ELEMENT;
+import static org.glassfish.web.LogFacade.SEND_ERROR_MULTIPLE_ELEMENT;
+import static org.glassfish.web.LogFacade.SSO_MAX_INACTIVE_SET;
+import static org.glassfish.web.LogFacade.SSO_REAP_INTERVAL_SET;
+import static org.glassfish.web.LogFacade.UNABLE_RECONFIGURE_ACCESS_LOG;
+import static org.glassfish.web.LogFacade.UNABLE_TO_LOAD_EXTENSION_SEVERE;
+import static org.glassfish.web.LogFacade.VS_DEFAULT_WEB_MODULE;
+import static org.glassfish.web.LogFacade.VS_DEFAULT_WEB_MODULE_DISABLED;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.logging.Handler;
+import java.util.logging.LogManager;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.ContainerListener;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.Pipeline;
+import org.apache.catalina.Realm;
+import org.apache.catalina.Valve;
+import org.apache.catalina.authenticator.AuthenticatorBase;
+import org.apache.catalina.authenticator.SingleSignOn;
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardHost;
+import org.apache.catalina.deploy.ErrorPage;
+import org.apache.catalina.valves.RemoteAddrValve;
+import org.apache.catalina.valves.RemoteHostValve;
+import org.glassfish.api.ActionReport;
+import org.glassfish.api.admin.ServerEnvironment;
+import org.glassfish.api.deployment.DeployCommandParameters;
+import org.glassfish.api.deployment.OpsParams;
+import org.glassfish.api.deployment.UndeployCommandParameters;
+import org.glassfish.api.deployment.archive.ArchiveHandler;
+import org.glassfish.api.deployment.archive.ReadableArchive;
+import org.glassfish.deployment.common.ApplicationConfigInfo;
+import org.glassfish.deployment.common.DeploymentContextImpl;
+import org.glassfish.deployment.common.DeploymentUtils;
+import org.glassfish.embeddable.GlassFishException;
+import org.glassfish.embeddable.web.ConfigException;
+import org.glassfish.embeddable.web.Context;
+import org.glassfish.embeddable.web.WebListener;
+import org.glassfish.embeddable.web.config.VirtualServerConfig;
+import org.glassfish.grizzly.Buffer;
+import org.glassfish.grizzly.Connection;
+import org.glassfish.grizzly.ConnectionProbe;
+import org.glassfish.grizzly.config.GenericGrizzlyListener;
+import org.glassfish.grizzly.config.dom.NetworkListener;
+import org.glassfish.grizzly.filterchain.FilterChainContext;
+import org.glassfish.grizzly.http.HttpCodecFilter;
+import org.glassfish.grizzly.http.HttpPacket;
+import org.glassfish.grizzly.http.HttpProbe;
+import org.glassfish.grizzly.http.HttpRequestPacket;
+import org.glassfish.grizzly.http.HttpResponsePacket;
+import org.glassfish.grizzly.http.util.HttpStatus;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.api.ClassLoaderHierarchy;
+import org.glassfish.internal.api.Globals;
+import org.glassfish.internal.api.ServerContext;
+import org.glassfish.internal.data.ApplicationInfo;
+import org.glassfish.internal.data.ApplicationRegistry;
+import org.glassfish.internal.deployment.Deployment;
+import org.glassfish.internal.deployment.ExtendedDeploymentContext;
+import org.glassfish.web.LogFacade;
+import org.glassfish.web.admin.monitor.RequestProbeProvider;
+import org.glassfish.web.deployment.archivist.WebArchivist;
+import org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl;
+import org.glassfish.web.loader.WebappClassLoader;
+import org.glassfish.web.valve.GlassFishValve;
+import org.jvnet.hk2.config.Transaction;
+import org.jvnet.hk2.config.TransactionFailure;
+import org.jvnet.hk2.config.types.Property;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
 import com.sun.enterprise.config.serverbeans.ApplicationRef;
 import com.sun.enterprise.config.serverbeans.Applications;
 import com.sun.enterprise.config.serverbeans.AuthRealm;
@@ -40,109 +158,18 @@
 import com.sun.enterprise.web.session.SessionCookieConfig;
 import com.sun.web.security.RealmAdapter;
 
-import org.apache.catalina.*;
-import org.apache.catalina.authenticator.AuthenticatorBase;
-import org.apache.catalina.authenticator.SingleSignOn;
-import org.apache.catalina.core.StandardContext;
-import org.apache.catalina.core.StandardHost;
-import org.apache.catalina.connector.Response;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.deploy.ErrorPage;
-import org.apache.catalina.valves.RemoteAddrValve;
-import org.apache.catalina.valves.RemoteHostValve;
-
-import org.glassfish.api.ActionReport;
-import org.glassfish.api.admin.ServerEnvironment;
-import org.glassfish.api.deployment.DeployCommandParameters;
-import org.glassfish.api.deployment.OpsParams;
-import org.glassfish.api.deployment.UndeployCommandParameters;
-import org.glassfish.api.deployment.archive.ArchiveHandler;
-import org.glassfish.api.deployment.archive.ReadableArchive;
-import org.glassfish.deployment.common.ApplicationConfigInfo;
-import org.glassfish.deployment.common.DeploymentContextImpl;
-import org.glassfish.deployment.common.DeploymentUtils;
-import org.glassfish.embeddable.CommandRunner;
-import org.glassfish.embeddable.GlassFishException;
-import org.glassfish.embeddable.web.Context;
-import org.glassfish.embeddable.web.ConfigException;
-import org.glassfish.embeddable.web.WebListener;
-import org.glassfish.embeddable.web.config.VirtualServerConfig;
-import org.glassfish.grizzly.Buffer;
-import org.glassfish.grizzly.Connection;
-import org.glassfish.grizzly.ConnectionProbe;
-import org.glassfish.grizzly.config.GenericGrizzlyListener;
-import org.glassfish.grizzly.config.dom.NetworkListener;
-import org.glassfish.grizzly.http.ContentEncoding;
-import org.glassfish.grizzly.http.HttpContent;
-import org.glassfish.grizzly.http.HttpCodecFilter;
-import org.glassfish.grizzly.http.HttpProbe;
-import org.glassfish.grizzly.http.HttpHeader;
-import org.glassfish.grizzly.http.HttpPacket;
-import org.glassfish.grizzly.http.HttpRequestPacket;
-import org.glassfish.grizzly.http.HttpResponsePacket;
-import org.glassfish.grizzly.http.TransferEncoding;
-import org.glassfish.grizzly.http.util.HttpStatus;
-import org.glassfish.grizzly.filterchain.FilterChainContext;
-import org.glassfish.hk2.api.ServiceLocator;
-import org.glassfish.hk2.api.ServiceLocatorFactory;
-import org.glassfish.web.LogFacade;
-import org.glassfish.web.admin.monitor.RequestProbeProvider;
-import org.glassfish.web.deployment.archivist.WebArchivist;
-import org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl;
-
-import org.glassfish.internal.api.ClassLoaderHierarchy;
-import org.glassfish.internal.api.ServerContext;
-import org.glassfish.internal.api.Globals;
-import org.glassfish.internal.data.ApplicationInfo;
-import org.glassfish.internal.data.ApplicationRegistry;
-import org.glassfish.internal.deployment.Deployment;
-import org.glassfish.internal.deployment.ExtendedDeploymentContext;
-import org.glassfish.web.loader.WebappClassLoader;
-import org.glassfish.web.valve.GlassFishValve;
-
-import org.jvnet.hk2.config.Transaction;
-import org.jvnet.hk2.config.TransactionFailure;
-import org.jvnet.hk2.config.types.Property;
-
-import java.io.File;
-import java.io.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.*;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogManager;
-import java.util.logging.Logger;
-import java.util.logging.LogRecord;
-
 import jakarta.servlet.http.Cookie;
 import jakarta.servlet.http.HttpServletRequest;
-import javax.xml.XMLConstants;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.*;
-
 
 /**
- * Standard implementation of a virtual server (aka virtual host) in
- * the iPlanet Application Server.
+ * Standard implementation of a virtual server (aka virtual host) in the iPlanet Application Server.
  */
 
-public class VirtualServer extends StandardHost
-        implements org.glassfish.embeddable.web.VirtualServer {
+public class VirtualServer extends StandardHost implements org.glassfish.embeddable.web.VirtualServer {
 
-    private static final String STATE = "state";
-    private static final String SSO_MAX_IDLE ="sso-max-inactive-seconds";
-    private static final String SSO_REAP_INTERVAL ="sso-reap-interval-seconds";
-    private static final String SSO_COOKIE_SECURE ="sso-cookie-secure";
+    private static final String SSO_MAX_IDLE = "sso-max-inactive-seconds";
+    private static final String SSO_REAP_INTERVAL = "sso-reap-interval-seconds";
     private static final String DISABLED = "disabled";
-    private static final String OFF = "off";
     private static final String ON = "on";
 
     /**
@@ -155,12 +182,10 @@
      */
     protected static final ResourceBundle rb = DEFAULT_LOGGER.getResourceBundle();
 
-
     // ------------------------------------------------------------ Constructor
 
     /**
-     * Default constructor that simply gets a handle to the web container
-     * subsystem's logger.
+     * Default constructor that simply gets a handle to the web container subsystem's logger.
      */
     public VirtualServer() {
         origPipeline = pipeline;
@@ -172,27 +197,24 @@
     // ----------------------------------------------------- Instance Variables
 
     /*
-     * The custom pipeline of this VirtualServer, which implements the
-     * following virtual server features:
+     * The custom pipeline of this VirtualServer, which implements the following virtual server features:
      *
-     * - state (disabled/off)
-     * - redirects
+     * - state (disabled/off) - redirects
      */
     private VirtualServerPipeline vsPipeline;
 
     /*
      * The original (standard) pipeline of this VirtualServer.
      *
-     * Only one (custom or original) pipeline may be active at any given time.
-     * Any updates (such as adding or removing valves) to the currently
-     * active pipeline are propagated to the other.
+     * Only one (custom or original) pipeline may be active at any given time. Any updates (such as adding or removing
+     * valves) to the currently active pipeline are propagated to the other.
      */
     private Pipeline origPipeline;
 
     /**
      * The id of this virtual server as specified in the configuration.
      */
-    private String _id = null;
+    private String _id;
 
     /**
      * The logger to use for logging this virtual server
@@ -202,8 +224,7 @@
     /**
      * The descriptive information about this implementation.
      */
-    private static final String _info =
-        "com.sun.enterprise.web.VirtualServer/1.0";
+    private static final String _info = "com.sun.enterprise.web.VirtualServer/1.0";
 
     /**
      * The config bean associated with this VirtualServer
@@ -216,16 +237,14 @@
     private MimeMap mimeMap;
 
     /*
-     * Indicates whether symbolic links from this virtual server's docroot
-     * are followed. This setting is inherited by all web modules deployed on
-     * this virtual server, unless overridden by a web modules allowLinking
-     * property in sun-web.xml.
+     * Indicates whether symbolic links from this virtual server's docroot are followed. This setting is inherited by all
+     * web modules deployed on this virtual server, unless overridden by a web modules allowLinking property in sun-web.xml.
      */
-    private boolean allowLinking = false;
+    private boolean allowLinking;
 
     private String[] cacheControls;
 
-    private ClassLoaderHierarchy clh;
+    private ClassLoaderHierarchy classLoaderHierarchy;
 
     private Domain domain;
 
@@ -239,19 +258,17 @@
     /*
      * The accesslog valve of this VirtualServer.
      *
-     * This valve is activated, that is, added to this virtual server's
-     * pipeline, only when access logging has been enabled. When acess logging
-     * has been disabled, this valve is removed from this virtual server's
-     * pipeline.
+     * This valve is activated, that is, added to this virtual server's pipeline, only when access logging has been enabled.
+     * When acess logging has been disabled, this valve is removed from this virtual server's pipeline.
      */
     private PEAccessLogValve accessLogValve;
 
     // The value of the ssoCookieSecure property
-    private String ssoCookieSecure = null;
+    private String ssoCookieSecure;
 
-    private boolean ssoCookieHttpOnly = false;
+    private boolean ssoCookieHttpOnly;
 
-    private String defaultContextPath = null;
+    private String defaultContextPath;
 
     private ServerContext serverContext;
 
@@ -261,23 +278,28 @@
 
     private WebContainer webContainer;
 
-    private boolean ssoFailoverEnabled = false;
+    private boolean ssoFailoverEnabled;
 
-    private volatile FileLoggerHandler fileLoggerHandler = null;
+    private volatile FileLoggerHandler fileLoggerHandler;
 
-    private volatile FileLoggerHandlerFactory fileLoggerHandlerFactory = null;
+    private volatile FileLoggerHandlerFactory fileLoggerHandlerFactory;
 
-    private Deployment deployment = null;
+    private Deployment deployment;
 
-    private ArchiveFactory factory = null;
+    private ArchiveFactory factory;
 
-    private ActionReport report = null;
+    private ActionReport report;
+
+    private VirtualServerConfig config;
+
+    private List<WebListener> listeners = new ArrayList<>();
 
     // ------------------------------------------------------------- Properties
 
     /**
      * Return the virtual server identifier.
      */
+    @Override
     public String getID() {
         return _id;
     }
@@ -287,6 +309,7 @@
      *
      * @param id New identifier for this virtual server
      */
+    @Override
     public void setID(String id) {
         _id = id;
     }
@@ -311,21 +334,19 @@
     /**
      * Gets the value of the allowLinking property of this virtual server.
      *
-     * @return true if symbolic links from this virtual server's docroot (as
-     * well as symbolic links from archives of web modules deployed on this
-     * virtual server) are followed, false otherwise
+     * @return true if symbolic links from this virtual server's docroot (as well as symbolic links from archives of web
+     * modules deployed on this virtual server) are followed, false otherwise
      */
     public boolean getAllowLinking() {
         return allowLinking;
     }
 
     /**
-     * Sets the allowLinking property of this virtual server, which determines
-     * whether symblic links from this virtual server's docroot are followed.
+     * Sets the allowLinking property of this virtual server, which determines whether symblic links from this virtual
+     * server's docroot are followed.
      *
-     * This property is inherited by all web modules deployed on this virtual
-     * server, unless overridden by the allowLinking property in a web module's
-     * sun-web.xml.
+     * This property is inherited by all web modules deployed on this virtual server, unless overridden by the allowLinking
+     * property in a web module's sun-web.xml.
      *
      * @param allowLinking Value of allowLinking property
      */
@@ -336,37 +357,36 @@
     /**
      * Gets the config bean associated with this VirtualServer.
      */
-    public com.sun.enterprise.config.serverbeans.VirtualServer getBean(){
+    public com.sun.enterprise.config.serverbeans.VirtualServer getBean() {
         return vsBean;
     }
 
     /**
      * Sets the config bean for this VirtualServer
      */
-    public void setBean(
-            com.sun.enterprise.config.serverbeans.VirtualServer vsBean){
+    public void setBean(com.sun.enterprise.config.serverbeans.VirtualServer vsBean) {
         this.vsBean = vsBean;
     }
 
     /**
      * Gets the mime map associated with this VirtualServer.
      */
-    public MimeMap getMimeMap(){
+    public MimeMap getMimeMap() {
         return mimeMap;
     }
 
     /**
      * Sets the mime map for this VirtualServer
      */
-    public void setMimeMap(MimeMap mimeMap){
+    public void setMimeMap(MimeMap mimeMap) {
         this.mimeMap = mimeMap;
     }
 
     /**
      * Gets the Cache-Control configuration of this VirtualServer.
      *
-     * @return Cache-Control configuration of this VirtualServer, or null if
-     * no such configuration exists for this VirtualServer
+     * @return Cache-Control configuration of this VirtualServer, or null if no such configuration exists for this
+     * VirtualServer
      */
     public String[] getCacheControls() {
         return cacheControls;
@@ -375,8 +395,7 @@
     /**
      * Sets the Cache-Control configuration for this VirtualServer
      *
-     * @param cacheControls Cache-Control configuration settings for this
-     * VirtualServer
+     * @param cacheControls Cache-Control configuration settings for this VirtualServer
      */
     public void setCacheControls(String[] cacheControls) {
         this.cacheControls = cacheControls;
@@ -386,6 +405,7 @@
         this.services = services;
     }
 
+    @Override
     public String getInfo() {
         return _info;
     }
@@ -399,7 +419,7 @@
     }
 
     public void setClassLoaderHierarchy(ClassLoaderHierarchy clh) {
-        this.clh = clh;
+        this.classLoaderHierarchy = clh;
     }
 
     public void setDomain(Domain domain) {
@@ -410,11 +430,10 @@
     public Container findChild(String contextRoot) {
         if (defaultContextPath != null && "/".equals(contextRoot)) {
             return super.findChild(defaultContextPath);
-        } else {
-            return super.findChild(contextRoot);
         }
-    }
 
+        return super.findChild(contextRoot);
+    }
 
     // --------------------------------------------------------- Public Methods
 
@@ -425,11 +444,9 @@
      * @param hreq the HttpServletRequest that has initiated the SSO session
      */
     @Override
-    public void configureSingleSignOnCookieSecure(Cookie ssoCookie,
-                                                  HttpServletRequest hreq) {
+    public void configureSingleSignOnCookieSecure(Cookie ssoCookie, HttpServletRequest hreq) {
         super.configureSingleSignOnCookieSecure(ssoCookie, hreq);
-        if (ssoCookieSecure != null &&
-                !ssoCookieSecure.equals(SessionCookieConfig.DYNAMIC_SECURE)) {
+        if (ssoCookieSecure != null && !ssoCookieSecure.equals(SessionCookieConfig.DYNAMIC_SECURE)) {
             ssoCookie.setSecure(Boolean.parseBoolean(ssoCookieSecure));
         }
     }
@@ -439,13 +456,12 @@
         ssoCookie.setHttpOnly(ssoCookieHttpOnly);
     }
 
-
     // ------------------------------------------------------ Lifecycle Methods
 
     /**
-     * Adds the given valve to the currently active pipeline, keeping the
-     * pipeline that is not currently active in sync.
+     * Adds the given valve to the currently active pipeline, keeping the pipeline that is not currently active in sync.
      */
+    @Override
     public synchronized void addValve(GlassFishValve valve) {
         super.addValve(valve);
         if (pipeline == vsPipeline) {
@@ -455,11 +471,11 @@
         }
     }
 
-
     /**
-     * Adds the given Tomcat-style valve to the currently active pipeline,
-     * keeping the pipeline that is not currently active in sync.
+     * Adds the given Tomcat-style valve to the currently active pipeline, keeping the pipeline that is not currently active
+     * in sync.
      */
+    @Override
     public synchronized void addValve(Valve valve) {
         super.addValve(valve);
         if (pipeline == vsPipeline) {
@@ -469,11 +485,10 @@
         }
     }
 
-
     /**
-     * Removes the given valve from the currently active pipeline, keeping the
-     * valve that is not currently active in sync.
+     * Removes the given valve from the currently active pipeline, keeping the valve that is not currently active in sync.
      */
+    @Override
     public synchronized void removeValve(GlassFishValve valve) {
         super.removeValve(valve);
         if (pipeline == vsPipeline) {
@@ -484,196 +499,173 @@
     }
 
     private ConfigBeansUtilities getConfigBeansUtilities() {
-        if (services == null) return null;
+        if (services == null) {
+            return null;
+        }
+
         return services.getService(ConfigBeansUtilities.class);
     }
 
     // ------------------------------------------------------ Protected Methods
 
     /**
-     * Gets the context root of the web module that the user/configuration
-     * has designated as the default-web-module for this virtual server.
+     * Gets the context root of the web module that the user/configuration has designated as the default-web-module for this
+     * virtual server.
      *
-     * The default-web-module for a virtual server is specified via the
-     * 'default-web-module' attribute of the 'virtual-server' element in
-     * server.xml. This is an optional attribute and if the configuration
-     * does not specify another web module (standalone or part of a
-     * j2ee-application) that is configured at a context-root="", then
-     * a default web module will be created and loaded. The value for this
-     * attribute is either "${standalone-web-module-name}" or
+     * The default-web-module for a virtual server is specified via the 'default-web-module' attribute of the
+     * 'virtual-server' element in server.xml. This is an optional attribute and if the configuration does not specify
+     * another web module (standalone or part of a j2ee-application) that is configured at a context-root="", then a default
+     * web module will be created and loaded. The value for this attribute is either "${standalone-web-module-name}" or
      * "${j2ee-app-name}:${web-module-uri}".
      *
-     * @return null if the default-web-module has not been specified or
-     *              if the web module specified either could not be found or
-     *              is disabled or does not specify this virtual server (if
-     *              it specifies a value for the virtual-servers attribute) or
-     *              if there was an error loading its deployment descriptors.
+     * @return null if the default-web-module has not been specified or if the web module specified either could not be
+     * found or is disabled or does not specify this virtual server (if it specifies a value for the virtual-servers
+     * attribute) or if there was an error loading its deployment descriptors.
      */
-    protected String getDefaultContextPath(Domain domain,
-            ApplicationRegistry appRegistry) {
-
+    protected String getDefaultContextPath(Domain domain, ApplicationRegistry appRegistry) {
         String contextRoot = null;
-        String wmID = getDefaultWebModuleID();
+        String webModuleID = getDefaultWebModuleID();
 
-        if (wmID != null) {
-            // Check if the default-web-module is part of a
-            // j2ee-application
+        if (webModuleID != null) {
+            // Check if the default-web-module is part of a Jakarta EE application
             Applications appsBean = domain.getApplications();
-            WebModuleConfig wmInfo = findWebModuleInJ2eeApp(appsBean, wmID,
-                                                            appRegistry);
+            WebModuleConfig wmInfo = findWebModuleInJ2eeApp(appsBean, webModuleID, appRegistry);
             if (wmInfo == null) {
                 ConfigBeansUtilities cbu = getConfigBeansUtilities();
                 if (cbu == null) {
                     contextRoot = null;
-                }
-                else {
-                    contextRoot = cbu.getContextRoot(wmID);
+                } else {
+                    contextRoot = cbu.getContextRoot(webModuleID);
                 }
             } else {
                 contextRoot = wmInfo.getContextPath();
             }
 
             if (contextRoot == null) {
-                Object[] params = { wmID, getID() };
-                _logger.log(Level.SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_NOT_FOUND, params);
+                Object[] params = { webModuleID, getID() };
+                _logger.log(SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_NOT_FOUND, params);
             }
         }
 
         return contextRoot;
     }
 
-    protected WebModuleConfig getDefaultWebModule(Domain domain,
-            WebArchivist webArchivist, ApplicationRegistry appRegistry) {
+    protected WebModuleConfig getDefaultWebModule(Domain domain, WebArchivist webArchivist, ApplicationRegistry appRegistry) {
+        WebModuleConfig webModuleConfig = null;
 
-        WebModuleConfig wmInfo = null;
-
-        String wmID = getDefaultWebModuleID();
-        if (wmID != null) {
-            // Check if the default-web-module is part of a
-            // j2ee-application
+        String webModuleID = getDefaultWebModuleID();
+        if (webModuleID != null) {
+            // Check if the default-web-module is part of a Jakarta EE application
             Applications appsBean = domain.getApplications();
-            wmInfo = findWebModuleInJ2eeApp(appsBean, wmID, appRegistry);
-            if (wmInfo == null) {
+            webModuleConfig = findWebModuleInJ2eeApp(appsBean, webModuleID, appRegistry);
+            if (webModuleConfig == null) {
                 ConfigBeansUtilities cbu = getConfigBeansUtilities();
                 String contextRoot = null;
                 String location = null;
                 if (cbu != null) {
-                    contextRoot = cbu.getContextRoot(wmID);
-                    location = cbu.getLocation(wmID);
+                    contextRoot = cbu.getContextRoot(webModuleID);
+                    location = cbu.getLocation(webModuleID);
                 }
 
-                if (contextRoot!=null && location != null) {
+                if (contextRoot != null && location != null) {
                     File docroot = new File(location);
-                    WebBundleDescriptorImpl wbd = webArchivist.getDefaultWebXmlBundleDescriptor();
-                    wmInfo = new WebModuleConfig();
-                    wbd.setName(Constants.DEFAULT_WEB_MODULE_NAME);
-                    wbd.setContextRoot(contextRoot);
-                    wmInfo.setLocation(docroot);
-                    wmInfo.setDescriptor(wbd);
-                    wmInfo.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
+                    WebBundleDescriptorImpl webBundleDescriptor = webArchivist.getDefaultWebXmlBundleDescriptor();
+                    webModuleConfig = new WebModuleConfig();
+                    webBundleDescriptor.setName(DEFAULT_WEB_MODULE_NAME);
+                    webBundleDescriptor.setContextRoot(contextRoot);
+                    webModuleConfig.setLocation(docroot);
+                    webModuleConfig.setDescriptor(webBundleDescriptor);
+                    webModuleConfig.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
                     WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
                         @Override
                         public WebappClassLoader run() {
                             return new WebappClassLoader(EmbeddedWebContainer.class.getClassLoader());
                         }
                     });
-                    wmInfo.setAppClassLoader(cloader);
+                    webModuleConfig.setAppClassLoader(cloader);
                 }
             }
 
-            if (wmInfo == null) {
-                _logger.log(Level.SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_NOT_FOUND, new Object[] {wmID, getID()});
+            if (webModuleConfig == null) {
+                _logger.log(SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_NOT_FOUND, new Object[] { webModuleID, getID() });
             }
         }
 
-        return wmInfo;
+        return webModuleConfig;
     }
 
-
     /**
-     * If a default web module has not yet been configured and added to this
-     * virtual server's list of web modules then return the configuration
-     * information needed in order to create a default web module for this
-     * virtual server.
+     * If a default web module has not yet been configured and added to this virtual server's list of web modules then
+     * return the configuration information needed in order to create a default web module for this virtual server.
      *
-     * This method should be invoked only after all the standalone modules
-     * and the modules within j2ee-application elements have been added to
-     * this virtual server's list of modules (only then will one know whether
-     * the user has already configured a default web module or not).
+     * This method should be invoked only after all the standalone modules and the modules within j2ee-application elements
+     * have been added to this virtual server's list of modules (only then will one know whether the user has already
+     * configured a default web module or not).
      */
-    public WebModuleConfig createSystemDefaultWebModuleIfNecessary(
-            WebArchivist webArchivist) {
-
-        WebModuleConfig wmInfo = null;
+    public WebModuleConfig createSystemDefaultWebModuleIfNecessary(WebArchivist webArchivist) {
+        WebModuleConfig webModuleConfig = null;
 
         // Add a default context only if one hasn't already been loaded
         // and then too only if docroot is not null
         //
         String docroot = getAppBase();
-        if (getDefaultWebModuleID() == null && findChild("") == null
-                && docroot != null) {
+        if (getDefaultWebModuleID() == null && findChild("") == null && docroot != null) {
 
-            WebBundleDescriptorImpl wbd =
-                webArchivist.getDefaultWebXmlBundleDescriptor();
-            wmInfo = new WebModuleConfig();
-            wbd.setModuleID(Constants.DEFAULT_WEB_MODULE_NAME);
-            wbd.setContextRoot("");
-            wmInfo.setLocation(new File(docroot));
-            wmInfo.setDescriptor(wbd);
-            wmInfo.setParentLoader(
-                serverContext.getCommonClassLoader());
+            WebBundleDescriptorImpl webBundleDescriptor = webArchivist.getDefaultWebXmlBundleDescriptor();
+            webModuleConfig = new WebModuleConfig();
+            webBundleDescriptor.setModuleID(DEFAULT_WEB_MODULE_NAME);
+            webBundleDescriptor.setContextRoot("");
+            webModuleConfig.setLocation(new File(docroot));
+            webModuleConfig.setDescriptor(webBundleDescriptor);
+            webModuleConfig.setParentLoader(serverContext.getCommonClassLoader());
             WebappClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
                 @Override
                 public WebappClassLoader run() {
                     return new WebappClassLoader(serverContext.getCommonClassLoader());
                 }
             });
+
             loader.start();
-            wmInfo.setAppClassLoader(loader);
-            if ( wbd.getApplication() == null ) {
+            webModuleConfig.setAppClassLoader(loader);
+
+            if (webBundleDescriptor.getApplication() == null) {
                 Application application = Application.createApplication();
                 application.setVirtual(true);
-                application.setName(Constants.DEFAULT_WEB_MODULE_NAME);
-                wbd.setApplication(application);
+                application.setName(DEFAULT_WEB_MODULE_NAME);
+                webBundleDescriptor.setApplication(application);
             }
         }
 
-        return wmInfo;
-
+        return webModuleConfig;
     }
 
     /**
-     * Returns the id of the default web module for this virtual server
-     * as specified in the 'default-web-module' attribute of the
-     * 'virtual-server' element.
+     * Returns the id of the default web module for this virtual server as specified in the 'default-web-module' attribute
+     * of the 'virtual-server' element.
      */
     protected String getDefaultWebModuleID() {
-        String wmID = vsBean.getDefaultWebModule();
-        if ("".equals(wmID)) {
-            wmID = null;
-        }
-        if (wmID != null && _logger.isLoggable(Level.FINE)) {
-            Object[] params = { wmID, _id };
-            _logger.log(Level.FINE, LogFacade.VS_DEFAULT_WEB_MODULE, params);
+        String webModuleID = vsBean.getDefaultWebModule();
+        if ("".equals(webModuleID)) {
+            webModuleID = null;
         }
 
-        return wmID;
+        if (webModuleID != null && _logger.isLoggable(FINE)) {
+            Object[] params = { webModuleID, _id };
+            _logger.log(FINE, VS_DEFAULT_WEB_MODULE, params);
+        }
+
+        return webModuleID;
     }
 
     /**
-     * Finds and returns information about a web module embedded within a
-     * J2EE application, which is identified by a string of the form
-     * <code>a:b</code> or <code>a#b</code>, where <code>a</code> is the name
-     * of the J2EE application and <code>b</code> is the name of the embedded
-     * web module.
+     * Finds and returns information about a web module embedded within a J2EE application, which is identified by a string
+     * of the form <code>a:b</code> or <code>a#b</code>, where <code>a</code> is the name of the J2EE application and
+     * <code>b</code> is the name of the embedded web module.
      *
-     * @return null if <code>id</code> does not identify a web module embedded
-     * within a J2EE application.
+     * @return null if <code>id</code> does not identify a web module embedded within a J2EE application.
      */
-    protected WebModuleConfig findWebModuleInJ2eeApp(Applications appsBean,
-            String id, ApplicationRegistry appRegistry) {
-
-        WebModuleConfig wmInfo = null;
+    protected WebModuleConfig findWebModuleInJ2eeApp(Applications appsBean, String id, ApplicationRegistry appRegistry) {
+        WebModuleConfig webModuleConfig = null;
 
         // Check for ':' separator
         int separatorIndex = id.indexOf(Constants.NAME_SEPARATOR);
@@ -686,13 +678,11 @@
             String moduleID = id.substring(separatorIndex + 1);
 
             com.sun.enterprise.config.serverbeans.Application appBean =
-                appsBean.getModule(
-                com.sun.enterprise.config.serverbeans.Application.class, appID);
+                appsBean.getModule(com.sun.enterprise.config.serverbeans.Application.class, appID);
 
             if ((appBean != null) && Boolean.valueOf(appBean.getEnabled())) {
                 String location = appBean.getLocation();
-                String moduleDir = DeploymentUtils.getRelativeEmbeddedModulePath(
-                                                            location, moduleID);
+                String moduleDir = DeploymentUtils.getRelativeEmbeddedModulePath(location, moduleID);
 
                 ApplicationInfo appInfo = appRegistry.get(appID);
                 Application app = null;
@@ -701,70 +691,62 @@
                 } else {
                     // XXX ApplicaionInfo is NULL after restart
                     Object[] params = { id, getID() };
-                    _logger.log(Level.SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_DISABLED,
-                            params);
-                    return wmInfo;
+                    _logger.log(SEVERE, VS_DEFAULT_WEB_MODULE_DISABLED, params);
+                    return webModuleConfig;
                 }
 
-                WebBundleDescriptorImpl wbd = app.getModuleByTypeAndUri(WebBundleDescriptorImpl.class, moduleID);
-                String webUri = wbd.getModuleDescriptor().getArchiveUri();
-                String contextRoot = wbd.getModuleDescriptor().getContextRoot();
+                WebBundleDescriptorImpl webBundleDescriptor = app.getModuleByTypeAndUri(WebBundleDescriptorImpl.class, moduleID);
+                String webUri = webBundleDescriptor.getModuleDescriptor().getArchiveUri();
+                String contextRoot = webBundleDescriptor.getModuleDescriptor().getContextRoot();
+
                 if (moduleID.equals(webUri)) {
                     StringBuilder dir = new StringBuilder(location);
                     dir.append(File.separator);
                     dir.append(moduleDir);
                     File docroot = new File(dir.toString());
-                    wmInfo = new WebModuleConfig();
-                    wbd.setName(moduleID);
-                    wbd.setContextRoot(contextRoot);
-                    wmInfo.setDescriptor(wbd);
-                    wmInfo.setLocation(docroot);
-                    wmInfo.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
+                    webModuleConfig = new WebModuleConfig();
+                    webBundleDescriptor.setName(moduleID);
+                    webBundleDescriptor.setContextRoot(contextRoot);
+                    webModuleConfig.setDescriptor(webBundleDescriptor);
+                    webModuleConfig.setLocation(docroot);
+                    webModuleConfig.setParentLoader(EmbeddedWebContainer.class.getClassLoader());
                     WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
                         @Override
                         public WebappClassLoader run() {
                             return new WebappClassLoader(EmbeddedWebContainer.class.getClassLoader());
                         }
                     });
-                    wmInfo.setAppClassLoader(cloader);
+                    webModuleConfig.setAppClassLoader(cloader);
 
                 }
             } else {
                 Object[] params = { id, getID() };
-                _logger.log(Level.SEVERE, LogFacade.VS_DEFAULT_WEB_MODULE_DISABLED,
-                            params);
+                _logger.log(SEVERE, VS_DEFAULT_WEB_MODULE_DISABLED, params);
             }
         }
 
-        return wmInfo;
+        return webModuleConfig;
     }
 
     /**
-     * Virtual servers are maintained in the reference contained
-     * in Server element. First, we need to find the server
-     * and then get the virtual server from the correct reference
+     * Virtual servers are maintained in the reference contained in Server element. First, we need to find the server and
+     * then get the virtual server from the correct reference
      *
      * @param appName Name of the app to get vs
      *
      * @return virtual servers as a string (separated by space or comma)
      *
-    private String getVirtualServers(String appName) {
-        String ret = null;
-        Server server = Globals.getDefaultHabitat().forContract(Server.class).get();
-        for (ApplicationRef appRef : server.getApplicationRef()) {
-            if (appRef.getRef().equals(appName)) {
-                return appRef.getVirtualServers();
-            }
-        }
-
-        return ret;
-    } */
-
+     * private String getVirtualServers(String appName) { String ret = null; Server server =
+     * Globals.getDefaultHabitat().forContract(Server.class).get(); for (ApplicationRef appRef : server.getApplicationRef())
+     * { if (appRef.getRef().equals(appName)) { return appRef.getVirtualServers(); } }
+     *
+     * return ret; }
+     */
 
     /**
      * Delete all aliases.
      */
-    public void clearAliases(){
+    public void clearAliases() {
         aliases = new String[0];
     }
 
@@ -815,14 +797,8 @@
     /**
      * Configures this virtual server.
      */
-    public void configure(
-                    String vsID,
-                    com.sun.enterprise.config.serverbeans.VirtualServer vsBean,
-                    String vsDocroot,
-                    String vsLogFile,
-                    MimeMap vsMimeMap,
-                    String logServiceFile,
-                    String logLevel) {
+    public void configure(String vsID, com.sun.enterprise.config.serverbeans.VirtualServer vsBean, String vsDocroot, String vsLogFile,
+            MimeMap vsMimeMap, String logServiceFile, String logLevel) {
         setDebug(debug);
         setAppBase(vsDocroot);
         setName(vsID);
@@ -833,12 +809,12 @@
         String defaultContextXmlLocation = Constants.DEFAULT_CONTEXT_XML;
         String defaultWebXmlLocation = Constants.DEFAULT_WEB_XML;
 
-        //Begin EE: 4920692 Make the default-web.xml be relocatable
+        // Begin EE: 4920692 Make the default-web.xml be relocatable
         Property prop = vsBean.getProperty("default-web-xml");
         if (prop != null) {
             defaultWebXmlLocation = prop.getValue();
         }
-        //End EE: 4920692 Make the default-web.xml be relocatable
+        // End EE: 4920692 Make the default-web.xml be relocatable
 
         // allowLinking
         boolean allowLinking = false;
@@ -872,8 +848,7 @@
     /**
      * Configures the valve_ and listener_ properties of this VirtualServer.
      */
-    protected void configureCatalinaProperties(){
-
+    protected void configureCatalinaProperties() {
         List<Property> props = vsBean.getProperty();
         if (props == null) {
             return;
@@ -884,9 +859,7 @@
             String propName = prop.getName();
             String propValue = prop.getValue();
             if (propName == null || propValue == null) {
-                _logger.log(Level.WARNING,
-                        LogFacade.NULL_VIRTUAL_SERVER_PROPERTY,
-                        getName());
+                _logger.log(WARNING, NULL_VIRTUAL_SERVER_PROPERTY, getName());
             }
 
             if (propName != null) {
@@ -894,76 +867,34 @@
                     addValve(propValue);
                 } else if (propName.startsWith("listener_")) {
                     addListener(propValue);
-                } else if (propName.equals("securePagesWithPragma")){
+                } else if (propName.equals("securePagesWithPragma")) {
                     setSecurePagesWithPragma(Boolean.valueOf(propValue));
                 }
             }
         }
     }
 
-
     /*
      * Configures this virtual server with the specified log file.
      *
-     * @param logFile The value of the virtual server's log-file attribute in
-     * the domain.xml
+     * @param logFile The value of the virtual server's log-file attribute in the domain.xml
      */
     synchronized void setLogFile(String logFile, String logLevel, String logServiceFile) {
 
-        /** catalina file logger code
-        String logPrefix = logFile;
-        String logDir = null;
-        String logSuffix = null;
-
-        if (logPrefix == null || logPrefix.equals("")) {
-            return;
-        }
-
-        int index = logPrefix.lastIndexOf(File.separatorChar);
-        if (index != -1) {
-            logDir = logPrefix.substring(0, index);
-            logPrefix = logPrefix.substring(index+1);
-        }
-
-        index = logPrefix.indexOf('.');
-        if (index != -1) {
-            logSuffix = logPrefix.substring(index);
-            logPrefix = logPrefix.substring(0, index);
-        }
-
-        logPrefix += "_";
-
-        FileLogger contextLogger = new FileLogger();
-        if (logDir != null) {
-            contextLogger.setDirectory(logDir);
-        }
-        contextLogger.setPrefix(logPrefix);
-        if (logSuffix != null) {
-            contextLogger.setSuffix(logSuffix);
-        }
-        contextLogger.setTimestamp(true);
-        contextLogger.setLevel(logLevel);
-         */
-
-
         /*
-         * Configure separate logger for this virtual server only if
-         * 'log-file' attribute of this <virtual-server> and 'file'
+         * Configure separate logger for this virtual server only if 'log-file' attribute of this <virtual-server> and 'file'
          * attribute of <log-service> are different (See 6189219).
          */
-        boolean noCustomLog = (logFile == null ||
-            (logServiceFile != null && new File(logFile).equals(
-                    new File(logServiceFile))));
+        boolean noCustomLog = (logFile == null || (logServiceFile != null && new File(logFile).equals(new File(logServiceFile))));
 
-        if ((fileLoggerHandler == null && noCustomLog) ||
-                (fileLoggerHandler != null && logFile != null &&
-                logFile.equals(fileLoggerHandler.getLogFile()))) {
+        if ((fileLoggerHandler == null && noCustomLog)
+                || (fileLoggerHandler != null && logFile != null && logFile.equals(fileLoggerHandler.getLogFile()))) {
             return;
         }
 
         Logger newLogger = null;
         FileLoggerHandler oldHandler = fileLoggerHandler;
-        //remove old handler
+        // remove old handler
         if (oldHandler != null) {
             _logger.removeHandler(oldHandler);
         }
@@ -986,7 +917,7 @@
                                 record.setResourceBundle(bundle);
                             }
                         }
-                        record.setThreadID((int)Thread.currentThread().getId());
+                        record.setThreadID((int) Thread.currentThread().getId());
                         super.log(record);
                     }
 
@@ -1000,7 +931,7 @@
                     public synchronized void addHandler(Handler handler) {
                         super.addHandler(handler);
                         if (handler instanceof FileLoggerHandler) {
-                            ((FileLoggerHandler)handler).associate();
+                            ((FileLoggerHandler) handler).associate();
                         }
                     }
 
@@ -1021,13 +952,13 @@
                             }
                             if (hasHandler) {
                                 super.removeHandler(handler);
-                                ((FileLoggerHandler)handler).disassociate();
+                                ((FileLoggerHandler) handler).disassociate();
                             }
                         }
                     }
                 };
 
-                synchronized(Logger.class) {
+                synchronized (Logger.class) {
                     LogManager.getLogManager().addLogger(newLogger);
                 }
             }
@@ -1068,10 +999,9 @@
      */
     void configureAliases() {
         List hosts = StringUtils.parseStringList(vsBean.getHosts(), ",");
-        for (int i=0; i < hosts.size(); i++ ){
-            String alias = hosts.get(i).toString();
-            if ( !alias.equalsIgnoreCase("localhost") &&
-                    !alias.equalsIgnoreCase("localhost.localdomain")){
+        for (Object host : hosts) {
+            String alias = host.toString();
+            if (!alias.equalsIgnoreCase("localhost") && !alias.equalsIgnoreCase("localhost.localdomain")) {
                 addAlias(alias);
             }
         }
@@ -1079,8 +1009,7 @@
 
     void configureAliases(String... hosts) {
         for (String host : hosts) {
-            if ( !host.equalsIgnoreCase("localhost") &&
-                    !host.equalsIgnoreCase("localhost.localdomain")){
+            if (!host.equalsIgnoreCase("localhost") && !host.equalsIgnoreCase("localhost.localdomain")) {
                 addAlias(host);
             }
         }
@@ -1089,15 +1018,15 @@
     /**
      * Configures this virtual server with its authentication realm.
      *
-     * Checks if this virtual server specifies any authRealm property, and
-     * if so, ensures that its value identifies a valid realm.
+     * Checks if this virtual server specifies any authRealm property, and if so, ensures that its value identifies a valid
+     * realm.
      *
      * @param securityService The security-service element from domain.xml
      */
     void configureAuthRealm(SecurityService securityService) {
         List<Property> properties = vsBean.getProperty();
         if (properties != null && properties.size() > 0) {
-            for (Property p: properties) {
+            for (Property p : properties) {
                 if (p != null && "authRealm".equals(p.getName())) {
                     authRealmName = p.getValue();
                     if (authRealmName != null) {
@@ -1105,8 +1034,7 @@
                         List<AuthRealm> rs = securityService.getAuthRealm();
                         if (rs != null && rs.size() > 0) {
                             for (AuthRealm r : rs) {
-                                if (r != null &&
-                                        r.getName().equals(authRealmName)) {
+                                if (r != null && r.getName().equals(authRealmName)) {
                                     realm = r;
                                     break;
                                 }
@@ -1114,8 +1042,7 @@
                         }
 
                         if (realm == null) {
-                            _logger.log(Level.SEVERE, LogFacade.INVALID_AUTH_REALM,
-                                new Object[] {getID(), authRealmName});
+                            _logger.log(SEVERE, INVALID_AUTH_REALM, new Object[] { getID(), authRealmName });
                         }
                     }
                     break;
@@ -1127,16 +1054,15 @@
     /**
      * Gets the value of the authRealm property of this virtual server.
      *
-     * @return The value of the authRealm property of this virtual server,
-     * or null of this virtual server does not have any such property
+     * @return The value of the authRealm property of this virtual server, or null of this virtual server does not have any
+     * such property
      */
     String getAuthRealmName() {
         return authRealmName;
     }
 
     /**
-     * Adds the <code>Valve</code> with the given class name to this
-     * VirtualServer.
+     * Adds the <code>Valve</code> with the given class name to this VirtualServer.
      *
      * @param valveName The valve's fully qualified class nam
      */
@@ -1147,44 +1073,46 @@
         } else if (valve instanceof GlassFishValve) {
             addValve((GlassFishValve) valve);
         } else {
-            _logger.log(Level.WARNING, LogFacade.NOT_A_VALVE, valveName);
+            _logger.log(WARNING, NOT_A_VALVE, valveName);
         }
     }
 
     /**
-     * Adds the Catalina listener with the given class name to this
-     * VirtualServer.
+     * Adds the Catalina listener with the given class name to this VirtualServer.
      *
      * @param listenerName The fully qualified class name of the listener
      */
     protected void addListener(String listenerName) {
         Object listener = safeLoadInstance(listenerName);
-
-        if ( listener == null ) return;
+        if (listener == null) {
+            return;
+        }
 
         if (listener instanceof ContainerListener) {
-            addContainerListener((ContainerListener)listener);
-        } else if (listener instanceof LifecycleListener){
-            addLifecycleListener((LifecycleListener)listener);
+            addContainerListener((ContainerListener) listener);
+        } else if (listener instanceof LifecycleListener) {
+            addLifecycleListener((LifecycleListener) listener);
         } else {
-            _logger.log(Level.SEVERE, LogFacade.INVALID_LISTENER_VIRTUAL_SERVER,
-                new Object[] {listenerName, getID()});
+            _logger.log(SEVERE, INVALID_LISTENER_VIRTUAL_SERVER, new Object[] { listenerName, getID() });
         }
     }
 
     @Override
     protected Object loadInstance(String className) throws Exception {
         // See IT 11674 for why CommonClassLoader must be used
-        Class clazz = serverContext.getCommonClassLoader().loadClass(className);
-        return clazz.newInstance();
+        return serverContext.getCommonClassLoader()
+                            .loadClass(className)
+                            .getDeclaredConstructor()
+                            .newInstance();
     }
 
-    private Object safeLoadInstance(String className){
-        try{
+    private Object safeLoadInstance(String className) {
+        try {
             return loadInstance(className);
-        } catch (Throwable ex){
-            _logger.log(Level.SEVERE, LogFacade.UNABLE_TO_LOAD_EXTENSION_SEVERE, ex);
+        } catch (Throwable ex) {
+            _logger.log(SEVERE, UNABLE_TO_LOAD_EXTENSION_SEVERE, ex);
         }
+
         return null;
     }
 
@@ -1192,7 +1120,6 @@
      * Configures this VirtualServer with its send-error properties.
      */
     void configureErrorPage() {
-
         ErrorPage errorPage = null;
 
         List<Property> props = vsBean.getProperty();
@@ -1204,9 +1131,7 @@
             String propName = prop.getName();
             String propValue = prop.getValue();
             if (propName == null || propValue == null) {
-                _logger.log(Level.WARNING,
-                        LogFacade.NULL_VIRTUAL_SERVER_PROPERTY,
-                        getID());
+                _logger.log(WARNING, NULL_VIRTUAL_SERVER_PROPERTY, getID());
                 continue;
             }
 
@@ -1222,38 +1147,32 @@
             String status = null;
 
             String[] errorParams = propValue.split(" ");
-            for (int j=0; j<errorParams.length; j++) {
+            for (String errorParam : errorParams) {
 
-                if (errorParams[j].startsWith("path=")) {
+                if (errorParam.startsWith("path=")) {
                     if (path != null) {
-                        _logger.log(Level.WARNING,
-                                LogFacade.SEND_ERROR_MULTIPLE_ELEMENT,
-                                new Object[] { propValue, getID(), "path" });
+                        _logger.log(WARNING, SEND_ERROR_MULTIPLE_ELEMENT, new Object[] { propValue, getID(), "path" });
                     }
-                    path = errorParams[j].substring("path=".length());
+                    path = errorParam.substring("path=".length());
                 }
 
-                if (errorParams[j].startsWith("reason=")) {
+                if (errorParam.startsWith("reason=")) {
                     if (reason != null) {
-                        _logger.log(Level.WARNING,
-                                LogFacade.SEND_ERROR_MULTIPLE_ELEMENT,
-                                new Object[] { propValue, getID(), "reason" });
+                        _logger.log(WARNING, SEND_ERROR_MULTIPLE_ELEMENT, new Object[] { propValue, getID(), "reason" });
                     }
-                    reason = errorParams[j].substring("reason=".length());
+                    reason = errorParam.substring("reason=".length());
                 }
 
-                if (errorParams[j].startsWith("code=")) {
+                if (errorParam.startsWith("code=")) {
                     if (status != null) {
-                        _logger.log(Level.WARNING,
-                                LogFacade.SEND_ERROR_MULTIPLE_ELEMENT,
-                                new Object[] { propValue, getID(), "code" });
+                        _logger.log(WARNING, SEND_ERROR_MULTIPLE_ELEMENT, new Object[] { propValue, getID(), "code" });
                     }
-                    status = errorParams[j].substring("code=".length());
+                    status = errorParam.substring("code=".length());
                 }
             }
 
             if (path == null || path.length() == 0) {
-                _logger.log(Level.WARNING, LogFacade.SEND_ERROR_MISSING_PATH, new Object[] { propValue, getID() });
+                _logger.log(WARNING, LogFacade.SEND_ERROR_MISSING_PATH, new Object[] { propValue, getID() });
             }
 
             errorPage = new ErrorPage();
@@ -1270,7 +1189,6 @@
      * Configures this VirtualServer with its redirect properties.
      */
     void configureRedirect() {
-
         vsPipeline.clearRedirects();
 
         List<Property> props = vsBean.getProperty();
@@ -1283,9 +1201,7 @@
             String propName = prop.getName();
             String propValue = prop.getValue();
             if (propName == null || propValue == null) {
-                _logger.log(Level.WARNING,
-                        LogFacade.NULL_VIRTUAL_SERVER_PROPERTY,
-                        getID());
+                _logger.log(WARNING, NULL_VIRTUAL_SERVER_PROPERTY, getID());
                 continue;
             }
 
@@ -1302,64 +1218,47 @@
             String escape = null;
 
             String[] redirectParams = propValue.split(" ");
-            for (int j=0; j<redirectParams.length; j++) {
+            for (String redirectParam : redirectParams) {
 
-                if (redirectParams[j].startsWith("from=")) {
+                if (redirectParam.startsWith("from=")) {
                     if (from != null) {
-                        _logger.log(Level.WARNING,
-                                LogFacade.REDIRECT_MULTIPLE_ELEMENT,
-                                new Object[] { propValue, getID(), "from" });
+                        _logger.log(WARNING, REDIRECT_MULTIPLE_ELEMENT, new Object[] { propValue, getID(), "from" });
                     }
-                    from = redirectParams[j].substring("from=".length());
+                    from = redirectParam.substring("from=".length());
                 }
 
-                if (redirectParams[j].startsWith("url=")) {
+                if (redirectParam.startsWith("url=")) {
                     if (url != null) {
-                        _logger.log(Level.WARNING,
-                                LogFacade.REDIRECT_MULTIPLE_ELEMENT,
-                                new Object[] { propValue, getID(), "url" });
+                        _logger.log(WARNING, REDIRECT_MULTIPLE_ELEMENT, new Object[] { propValue, getID(), "url" });
                     }
-                    url = redirectParams[j].substring("url=".length());
+                    url = redirectParam.substring("url=".length());
                 }
 
-                if (redirectParams[j].startsWith("url-prefix=")) {
+                if (redirectParam.startsWith("url-prefix=")) {
                     if (urlPrefix != null) {
-                        _logger.log(Level.WARNING,
-                                LogFacade.REDIRECT_MULTIPLE_ELEMENT,
-                                new Object[] { propValue, getID(), "url-prefix" });
+                        _logger.log(WARNING, REDIRECT_MULTIPLE_ELEMENT, new Object[] { propValue, getID(), "url-prefix" });
                     }
-                    urlPrefix = redirectParams[j].substring(
-                                                    "url-prefix=".length());
+                    urlPrefix = redirectParam.substring("url-prefix=".length());
                 }
 
-                if (redirectParams[j].startsWith("escape=")) {
+                if (redirectParam.startsWith("escape=")) {
                     if (escape != null) {
-                        _logger.log(Level.WARNING,
-                                LogFacade.REDIRECT_MULTIPLE_ELEMENT,
-                                new Object[] { propValue, getID(), "escape" });
+                        _logger.log(WARNING, REDIRECT_MULTIPLE_ELEMENT, new Object[] { propValue, getID(), "escape" });
                     }
-                    escape = redirectParams[j].substring("escape=".length());
+                    escape = redirectParam.substring("escape=".length());
                 }
             }
 
             if (from == null || from.length() == 0) {
-                _logger.log(Level.WARNING,
-                        LogFacade.REDIRECT_MULTIPLE_ELEMENT,
-                        new Object[] { propValue, getID() });
+                _logger.log(WARNING, REDIRECT_MULTIPLE_ELEMENT, new Object[] { propValue, getID() });
             }
 
             // Either url or url-prefix (but not both!) must be present
-            if ((url == null || url.length() == 0)
-                    && (urlPrefix == null || urlPrefix.length() == 0)) {
-                _logger.log(Level.WARNING,
-                        LogFacade.REDIRECT_MISSING_URL_OR_URL_PREFIX,
-                        new Object[] { propValue, getID() });
+            if ((url == null || url.length() == 0) && (urlPrefix == null || urlPrefix.length() == 0)) {
+                _logger.log(WARNING, REDIRECT_MISSING_URL_OR_URL_PREFIX, new Object[] { propValue, getID() });
             }
-            if (url != null && url.length() > 0
-                    && urlPrefix != null && urlPrefix.length() > 0) {
-                _logger.log(Level.WARNING,
-                        LogFacade.REDIRECT_BOTH_URL_AND_URL_PREFIX,
-                        new Object[] { propValue, getID() });
+            if (url != null && url.length() > 0 && urlPrefix != null && urlPrefix.length() > 0) {
+                _logger.log(WARNING, REDIRECT_BOTH_URL_AND_URL_PREFIX, new Object[] { propValue, getID() });
             }
 
             boolean escapeURI = true;
@@ -1369,9 +1268,7 @@
                 } else if ("no".equalsIgnoreCase(escape)) {
                     escapeURI = false;
                 } else {
-                    _logger.log(Level.WARNING,
-                        LogFacade.REDIRECT_INVALID_ESCAPE,
-                        new Object[] { propValue, getID() });
+                    _logger.log(WARNING, LogFacade.REDIRECT_INVALID_ESCAPE, new Object[] { propValue, getID() });
                 }
             }
 
@@ -1391,23 +1288,19 @@
     /**
      * Configures the SSO valve of this VirtualServer.
      */
-    void configureSingleSignOn(boolean globalSSOEnabled,
-            WebContainerFeatureFactory webContainerFeatureFactory,
-            boolean ssoFailoverEnabled) {
-
-
+    void configureSingleSignOn(boolean globalSSOEnabled, WebContainerFeatureFactory webContainerFeatureFactory, boolean ssoFailoverEnabled) {
         if (!isSSOEnabled(globalSSOEnabled)) {
             /*
              * Disable SSO
              */
-            if (_logger.isLoggable(Level.FINE)) {
-                _logger.log(Level.FINE, LogFacade.DISABLE_SSO, getID());
+            if (_logger.isLoggable(FINE)) {
+                _logger.log(FINE, LogFacade.DISABLE_SSO, getID());
             }
 
             boolean hasExistingSSO = false;
             // Remove existing SSO valve (if any)
             GlassFishValve[] valves = getValves();
-            for (int i=0; valves!=null && i<valves.length; i++) {
+            for (int i = 0; valves != null && i < valves.length; i++) {
                 if (valves[i] instanceof SingleSignOn) {
                     removeValve(valves[i]);
                     hasExistingSSO = true;
@@ -1423,17 +1316,17 @@
             /*
              * Enable SSO
              */
-            if (_logger.isLoggable(Level.FINE)) {
-                _logger.log(Level.FINE, LogFacade.ENABLE_SSO, getID());
+            if (_logger.isLoggable(FINE)) {
+                _logger.log(FINE, ENABLE_SSO, getID());
             }
 
             GlassFishSingleSignOn sso = null;
 
-            //find existing SSO (if any), in case of a reconfig
+            // find existing SSO (if any), in case of a reconfig
             GlassFishValve[] valves = getValves();
-            for (int i=0; valves!=null && i<valves.length; i++) {
+            for (int i = 0; valves != null && i < valves.length; i++) {
                 if (valves[i] instanceof GlassFishSingleSignOn) {
-                    sso = (GlassFishSingleSignOn)valves[i];
+                    sso = (GlassFishSingleSignOn) valves[i];
                     break;
                 }
             }
@@ -1445,8 +1338,7 @@
             }
 
             if (sso == null) {
-                SSOFactory ssoFactory =
-                    webContainerFeatureFactory.getSSOFactory();
+                SSOFactory ssoFactory = webContainerFeatureFactory.getSSOFactory();
                 sso = ssoFactory.createSingleSignOnValve(getName());
                 this.ssoFailoverEnabled = ssoFailoverEnabled;
                 setSingleSignOnForChildren(sso);
@@ -1456,17 +1348,17 @@
             // set max idle time if given
             Property idle = vsBean.getProperty(SSO_MAX_IDLE);
             if (idle != null && idle.getValue() != null) {
-                if (_logger.isLoggable(Level.FINE)) {
-                    _logger.log(Level.FINE, LogFacade.SSO_MAX_INACTIVE_SET, new Object[]{idle.getValue(), getID()});
+                if (_logger.isLoggable(FINE)) {
+                    _logger.log(FINE, SSO_MAX_INACTIVE_SET, new Object[] { idle.getValue(), getID() });
                 }
                 sso.setMaxInactive(Integer.parseInt(idle.getValue()));
             }
 
             // set expirer thread sleep time if given
             Property expireTime = vsBean.getProperty(SSO_REAP_INTERVAL);
-            if (expireTime !=null && expireTime.getValue() != null) {
-                if (_logger.isLoggable(Level.FINE)) {
-                    _logger.log(Level.FINE, LogFacade.SSO_REAP_INTERVAL_SET);
+            if (expireTime != null && expireTime.getValue() != null) {
+                if (_logger.isLoggable(FINE)) {
+                    _logger.log(FINE, SSO_REAP_INTERVAL_SET);
                 }
                 sso.setReapInterval(Integer.parseInt(expireTime.getValue()));
             }
@@ -1479,14 +1371,11 @@
     /**
      * Configures this VirtualServer with its state (on | off | disabled).
      */
-    void configureState(){
+    void configureState() {
         String stateValue = vsBean.getState();
-        if (!stateValue.equalsIgnoreCase(ON) &&
-                getName().equalsIgnoreCase(
-                    org.glassfish.api.web.Constants.ADMIN_VS)){
+        if (!stateValue.equalsIgnoreCase(ON) && getName().equalsIgnoreCase(org.glassfish.api.web.Constants.ADMIN_VS)) {
             throw new IllegalArgumentException(
-                "virtual-server " + org.glassfish.api.web.Constants.ADMIN_VS +
-                " state property cannot be modified");
+                "virtual-server " + ADMIN_VS + " state property cannot be modified");
         }
 
         if (stateValue.equalsIgnoreCase(DISABLED)) {
@@ -1503,11 +1392,9 @@
     /**
      * Configures the Remote Address Filter valve of this VirtualServer.
      *
-     * This valve enforces request accpetance/denial based on the string
-     * representation of the remote client's IP address.
+     * This valve enforces request accpetance/denial based on the string representation of the remote client's IP address.
      */
     void configureRemoteAddressFilterValve() {
-
         Property allow = vsBean.getProperty("allowRemoteAddress");
         Property deny = vsBean.getProperty("denyRemoteAddress");
         String allowStr = null;
@@ -1525,27 +1412,25 @@
     /**
      * Configures the Remote Address Filter valve of this VirtualServer.
      *
-     * This valve enforces request accpetance/denial based on the string
-     * representation of the remote client's IP address.
+     * This valve enforces request accpetance/denial based on the string representation of the remote client's IP address.
      */
     protected void configureRemoteAddressFilterValve(String allow, String deny) {
-
         RemoteAddrValve remoteAddrValve = null;
 
-        if (allow != null || deny != null)  {
+        if (allow != null || deny != null) {
             remoteAddrValve = new RemoteAddrValve();
         }
 
         if (allow != null) {
-            if (_logger.isLoggable(Level.FINE)) {
-                _logger.log(Level.FINE, LogFacade.ALLOW_ACCESS, new Object[]{getID(), allow});
+            if (_logger.isLoggable(FINE)) {
+                _logger.log(FINE, ALLOW_ACCESS, new Object[] { getID(), allow });
             }
             remoteAddrValve.setAllow(allow);
         }
 
         if (deny != null) {
-            if (_logger.isLoggable(Level.FINE)) {
-                _logger.log(Level.FINE, LogFacade.DENY_ACCESS, new Object[]{getID(), deny});
+            if (_logger.isLoggable(FINE)) {
+                _logger.log(FINE, DENY_ACCESS, new Object[] { getID(), deny });
             }
             remoteAddrValve.setDeny(deny);
         }
@@ -1553,7 +1438,7 @@
         if (remoteAddrValve != null) {
             // Remove existing RemoteAddrValve (if any), in case of a reconfig
             GlassFishValve[] valves = getValves();
-            for (int i=0; valves!=null && i<valves.length; i++) {
+            for (int i = 0; valves != null && i < valves.length; i++) {
                 if (valves[i] instanceof RemoteAddrValve) {
                     removeValve(valves[i]);
                     break;
@@ -1566,48 +1451,46 @@
     /**
      * Configures the Remote Host Filter valve of this VirtualServer.
      *
-     * This valve enforces request acceptance/denial based on the name of the
-     * remote host from where the request originated.
+     * This valve enforces request acceptance/denial based on the name of the remote host from where the request originated.
      */
     void configureRemoteHostFilterValve() {
-
         Property allow = vsBean.getProperty("allowRemoteHost");
         Property deny = vsBean.getProperty("denyRemoteHost");
         String allowStr = null;
         String denyStr = null;
+
         if (allow != null) {
             allowStr = allow.getValue();
         }
         if (deny != null) {
             denyStr = deny.getValue();
         }
-        configureRemoteHostFilterValve(allowStr, denyStr);
 
+        configureRemoteHostFilterValve(allowStr, denyStr);
     }
 
     void configureRemoteHostFilterValve(String allow, String deny) {
-
         RemoteHostValve remoteHostValve = null;
 
-        if (allow != null || deny != null)  {
+        if (allow != null || deny != null) {
             remoteHostValve = new RemoteHostValve();
         }
         if (allow != null) {
-            if (_logger.isLoggable(Level.FINE)) {
-                _logger.log(Level.FINE, LogFacade.ALLOW_ACCESS, new Object[]{getID(), allow});
+            if (_logger.isLoggable(FINE)) {
+                _logger.log(FINE, ALLOW_ACCESS, new Object[] { getID(), allow });
             }
             remoteHostValve.setAllow(allow);
         }
         if (deny != null) {
-            if (_logger.isLoggable(Level.FINE)) {
-                _logger.log(Level.FINE, LogFacade.DENY_ACCESS, new Object[]{getID(), deny});
+            if (_logger.isLoggable(FINE)) {
+                _logger.log(FINE, DENY_ACCESS, new Object[] { getID(), deny });
             }
             remoteHostValve.setDeny(deny);
         }
         if (remoteHostValve != null) {
             // Remove existing RemoteHostValve (if any), in case of a reconfig
             GlassFishValve[] valves = getValves();
-            for (int i=0; valves!=null && i<valves.length; i++) {
+            for (int i = 0; valves != null && i < valves.length; i++) {
                 if (valves[i] instanceof RemoteHostValve) {
                     removeValve(valves[i]);
                     break;
@@ -1629,7 +1512,7 @@
                         if (grizzlyListener.isAjpEnabled()) {
                             continue;
                         }
-                        _logger.log(Level.SEVERE, LogFacade.CODE_FILTERS_NULL, new Object[] {listener.getName(), codecFilters});
+                        _logger.log(SEVERE, CODE_FILTERS_NULL, new Object[] { listener.getName(), codecFilters });
                     } else {
                         for (HttpCodecFilter codecFilter : codecFilters) {
                             if (codecFilter.getMonitoringConfig().getProbes().length == 0) {
@@ -1658,49 +1541,40 @@
                     });
 
                 } else {
-                    _logger.log(Level.SEVERE, LogFacade.PROXY_NULL, new Object[] {listener.getName()});
+                    _logger.log(SEVERE, LogFacade.PROXY_NULL, new Object[] { listener.getName() });
                 }
 
             } catch (Exception ex) {
-                _logger.log(Level.SEVERE, LogFacade.ADD_HTTP_PROBES_ERROR, ex);
+                _logger.log(SEVERE, LogFacade.ADD_HTTP_PROBES_ERROR, ex);
             }
         }
     }
 
-
     /**
-     * Reconfigures the access log of this VirtualServer with its
-     * updated access log related properties.
+     * Reconfigures the access log of this VirtualServer with its updated access log related properties.
      */
-    void reconfigureAccessLog(String globalAccessLogBufferSize,
-                              String globalAccessLogWriteInterval,
-                              ServiceLocator services,
-                              Domain domain,
-                              boolean globalAccessLoggingEnabled) {
+    void reconfigureAccessLog(String globalAccessLogBufferSize, String globalAccessLogWriteInterval, ServiceLocator services, Domain domain, boolean globalAccessLoggingEnabled) {
         try {
             if (accessLogValve.isStarted()) {
                 accessLogValve.stop();
             }
-            boolean start = accessLogValve.updateVirtualServerProperties(
-                vsBean.getId(), vsBean, domain, services,
-                globalAccessLogBufferSize, globalAccessLogWriteInterval);
+            boolean start = accessLogValve.updateVirtualServerProperties(vsBean.getId(), vsBean, domain, services,
+                    globalAccessLogBufferSize, globalAccessLogWriteInterval);
             if (start && isAccessLoggingEnabled(globalAccessLoggingEnabled)) {
                 enableAccessLogging();
             } else {
                 disableAccessLogging();
             }
         } catch (LifecycleException le) {
-            _logger.log(Level.SEVERE, LogFacade.UNABLE_RECONFIGURE_ACCESS_LOG, le);
+            _logger.log(SEVERE, UNABLE_RECONFIGURE_ACCESS_LOG, le);
         }
     }
 
     /**
-     * Reconfigures the access log of this VirtualServer with the
-     * updated attributes of the access-log element from domain.xml.
+     * Reconfigures the access log of this VirtualServer with the updated attributes of the access-log element from
+     * domain.xml.
      */
-    void reconfigureAccessLog(
-            HttpService httpService,
-            WebContainerFeatureFactory webcontainerFeatureFactory) {
+    void reconfigureAccessLog(HttpService httpService, WebContainerFeatureFactory webcontainerFeatureFactory) {
 
         try {
             boolean restart = false;
@@ -1708,9 +1582,7 @@
                 accessLogValve.stop();
                 restart = true;
             }
-            accessLogValve.updateAccessLogAttributes(
-                httpService,
-                webcontainerFeatureFactory);
+            accessLogValve.updateAccessLogAttributes(httpService, webcontainerFeatureFactory);
             if (restart) {
                 accessLogValve.start();
                 for (HttpProbeImpl p : getHttpProbeImpl()) {
@@ -1718,7 +1590,7 @@
                 }
             }
         } catch (LifecycleException le) {
-            _logger.log(Level.SEVERE, LogFacade.UNABLE_RECONFIGURE_ACCESS_LOG, le);
+            _logger.log(SEVERE, UNABLE_RECONFIGURE_ACCESS_LOG, le);
         }
     }
 
@@ -1730,9 +1602,8 @@
     }
 
     /**
-     * Enables access logging for this virtual server, by adding its
-     * accesslog valve to its pipeline, or starting its accesslog valve
-     * if it is already present in the pipeline.
+     * Enables access logging for this virtual server, by adding its accesslog valve to its pipeline, or starting its
+     * accesslog valve if it is already present in the pipeline.
      */
     void enableAccessLogging() {
         if (!isAccessLogValveActivated()) {
@@ -1747,35 +1618,32 @@
                     p.enableAccessLogging();
                 }
             } catch (LifecycleException le) {
-                _logger.log(Level.SEVERE, LogFacade.UNABLE_RECONFIGURE_ACCESS_LOG, le);
+                _logger.log(SEVERE, UNABLE_RECONFIGURE_ACCESS_LOG, le);
             }
         }
     }
 
     /**
-     * Disables access logging for this virtual server, by removing its
-     * accesslog valve from its pipeline.
+     * Disables access logging for this virtual server, by removing its accesslog valve from its pipeline.
      */
     void disableAccessLogging() {
         removeValve(accessLogValve);
-        for (HttpProbeImpl p : getHttpProbeImpl()) {
-            p.disableAccessLogging();
+        for (HttpProbeImpl httpProbe : getHttpProbeImpl()) {
+            httpProbe.disableAccessLogging();
         }
     }
 
     /**
-     * @return true if the accesslog valve of this virtual server has been
-     * activated, that is, added to this virtual server's pipeline; false
-     * otherwise
+     * @return true if the accesslog valve of this virtual server has been activated, that is, added to this virtual
+     * server's pipeline; false otherwise
      */
     private boolean isAccessLogValveActivated() {
-
-        Pipeline p = getPipeline();
-        if (p != null) {
-            GlassFishValve[] valves = p.getValves();
+        Pipeline pipeline = getPipeline();
+        if (pipeline != null) {
+            GlassFishValve[] valves = pipeline.getValves();
             if (valves != null) {
-                for (int i=0; i<valves.length; i++) {
-                    if (valves[i] instanceof PEAccessLogValve) {
+                for (GlassFishValve element : valves) {
+                    if (element instanceof PEAccessLogValve) {
                         return true;
                     }
                 }
@@ -1788,7 +1656,7 @@
     /**
      * Configures the cache control of this VirtualServer
      */
-    void configureCacheControl(String cacheControl){
+    void configureCacheControl(String cacheControl) {
         if (cacheControl != null) {
             List<String> values = StringUtils.parseStringList(cacheControl, ",");
             if (values != null && !values.isEmpty()) {
@@ -1807,17 +1675,17 @@
         if (vsBean != null) {
             ssoEnabled = vsBean.getSsoEnabled();
         }
-        return "inherit".equals(ssoEnabled) && globalSSOEnabled
-            || ConfigBeansUtilities.toBoolean(ssoEnabled);
+
+        return "inherit".equals(ssoEnabled) && globalSSOEnabled || ConfigBeansUtilities.toBoolean(ssoEnabled);
     }
 
     private void setSingleSignOnForChildren(SingleSignOn sso) {
         for (Container container : findChildren()) {
             if (container instanceof StandardContext) {
-                StandardContext context = (StandardContext)container;
-                for (GlassFishValve valve: context.getValves()) {
+                StandardContext context = (StandardContext) container;
+                for (GlassFishValve valve : context.getValves()) {
                     if (valve instanceof AuthenticatorBase) {
-                        ((AuthenticatorBase)valve).setSingleSignOn(sso);
+                        ((AuthenticatorBase) valve).setSingleSignOn(sso);
                         break;
                     }
                 }
@@ -1828,41 +1696,34 @@
     /**
      * Determines whether access logging is enabled for this virtual server.
      *
-     * @param globalAccessLoggingEnabled The value of the
-     * accessLoggingEnabled property of the http-service element
+     * @param globalAccessLoggingEnabled The value of the accessLoggingEnabled property of the http-service element
      *
-     * @return true if access logging is enabled for this virtual server,
-     * false otherwise.
+     * @return true if access logging is enabled for this virtual server, false otherwise.
      */
     boolean isAccessLoggingEnabled(boolean globalAccessLoggingEnabled) {
         String enabled = vsBean.getAccessLoggingEnabled();
-        return "inherit".equals(enabled) && globalAccessLoggingEnabled ||
-            ConfigBeansUtilities.toBoolean(enabled);
+        return "inherit".equals(enabled) && globalAccessLoggingEnabled || ConfigBeansUtilities.toBoolean(enabled);
     }
 
     @Override
     public void setRealm(Realm realm) {
         if ((realm != null) && !(realm instanceof RealmAdapter)) {
-            _logger.log(Level.SEVERE, LogFacade.IGNORE_INVALID_REALM,
-                    new Object[] { realm.getClass().getName(),
-                        RealmAdapter.class.getName()});
+            _logger.log(SEVERE, IGNORE_INVALID_REALM,
+                    new Object[] { realm.getClass().getName(), RealmAdapter.class.getName() });
         } else {
             super.setRealm(realm);
         }
     }
 
     /**
-     * Configures the security level of the SSO cookie for this virtual
-     * server, based on the value of its sso-cookie-secure attribute
+     * Configures the security level of the SSO cookie for this virtual server, based on the value of its sso-cookie-secure
+     * attribute
      */
     private void configureSingleSignOnCookieSecure() {
         String cookieSecure = vsBean.getSsoCookieSecure();
-        if (!"true".equalsIgnoreCase(cookieSecure) &&
-                !"false".equalsIgnoreCase(cookieSecure) &&
-                !cookieSecure.equalsIgnoreCase(
-                    SessionCookieConfig.DYNAMIC_SECURE)) {
-            _logger.log(Level.WARNING, LogFacade.INVALID_SSO_COOKIE_SECURE,
-                        new Object[] {cookieSecure, getID()});
+        if (!"true".equalsIgnoreCase(cookieSecure) && !"false".equalsIgnoreCase(cookieSecure)
+                && !cookieSecure.equalsIgnoreCase(SessionCookieConfig.DYNAMIC_SECURE)) {
+            _logger.log(WARNING, LogFacade.INVALID_SSO_COOKIE_SECURE, new Object[] { cookieSecure, getID() });
         } else {
             ssoCookieSecure = cookieSecure;
         }
@@ -1875,14 +1736,13 @@
     /**
      * Configures the error report valve of this VirtualServer.
      *
-     * <p>The error report valve of a virtual server is specified through
-     * a property with name <i>errorReportValve</i>, whose value is the
-     * valve's fully qualified classname. A null or empty classname
-     * disables the error report valve and therefore the container's
-     * default error page mechanism for error responses.
+     * <p>
+     * The error report valve of a virtual server is specified through a property with name <i>errorReportValve</i>, whose
+     * value is the valve's fully qualified classname. A null or empty classname disables the error report valve and
+     * therefore the container's default error page mechanism for error responses.
      */
     void configureErrorReportValve() {
-        Property prop = vsBean.getProperty(Constants.ERROR_REPORT_VALVE);
+        Property prop = vsBean.getProperty(ERROR_REPORT_VALVE);
         if (prop != null) {
             setErrorReportValveClass(prop.getValue());
         }
@@ -1907,15 +1767,13 @@
     // ----------------------------------------------------- embedded methods
 
 
-    private VirtualServerConfig config;
-
-    private List<WebListener> listeners = new ArrayList<WebListener>();
 
     /**
      * Sets the docroot of this <tt>VirtualServer</tt>.
      *
      * @param docRoot the docroot of this <tt>VirtualServer</tt>.
      */
+    @Override
     public void setDocRoot(File docRoot) {
         this.setAppBase(docRoot.getPath());
     }
@@ -1923,46 +1781,44 @@
     /**
      * Gets the docroot of this <tt>VirtualServer</tt>.
      */
+    @Override
     public File getDocRoot() {
         return new File(getAppBase());
     }
 
     /**
-     * Sets the collection of <tt>WebListener</tt> instances from which
-     * this <tt>VirtualServer</tt> receives requests.
+     * Sets the collection of <tt>WebListener</tt> instances from which this <tt>VirtualServer</tt> receives requests.
      *
-     * @param webListeners the collection of <tt>WebListener</tt> instances from which
-     * this <tt>VirtualServer</tt> receives requests.
+     * @param webListeners the collection of <tt>WebListener</tt> instances from which this <tt>VirtualServer</tt> receives
+     * requests.
      */
-    public void setWebListeners(WebListener...  webListeners) {
+    public void setWebListeners(WebListener... webListeners) {
         if (webListeners != null) {
             listeners = Arrays.asList(webListeners);
         }
     }
 
     /**
-     * Gets the collection of <tt>WebListener</tt> instances from which
-     * this <tt>VirtualServer</tt> receives requests.
+     * Gets the collection of <tt>WebListener</tt> instances from which this <tt>VirtualServer</tt> receives requests.
      *
-     * @return the collection of <tt>WebListener</tt> instances from which
-     * this <tt>VirtualServer</tt> receives requests.
+     * @return the collection of <tt>WebListener</tt> instances from which this <tt>VirtualServer</tt> receives requests.
      */
+    @Override
     public Collection<WebListener> getWebListeners() {
         return listeners;
     }
 
     /**
-     * Registers the given <tt>Context</tt> with this <tt>VirtualServer</tt>
-     * at the given context root.
+     * Registers the given <tt>Context</tt> with this <tt>VirtualServer</tt> at the given context root.
      *
-     * <p>If this <tt>VirtualServer</tt> has already been started, the
-     * given <tt>context</tt> will be started as well.
+     * <p>
+     * If this <tt>VirtualServer</tt> has already been started, the given <tt>context</tt> will be started as well.
      */
-    public void addContext(Context context, String contextRoot)
-        throws ConfigException, GlassFishException {
+    @Override
+    public void addContext(Context context, String contextRoot) throws ConfigException, GlassFishException {
 
-        if (_logger.isLoggable(Level.FINE)) {
-           _logger.log(Level.FINE, LogFacade.VS_ADDED_CONTEXT);
+        if (_logger.isLoggable(FINE)) {
+            _logger.log(FINE, LogFacade.VS_ADDED_CONTEXT);
         }
 
         if (!(context instanceof ContextFacade)) {
@@ -1971,21 +1827,23 @@
         }
 
         if (!contextRoot.startsWith("/")) {
-            contextRoot = "/"+contextRoot;
+            contextRoot = "/" + contextRoot;
         }
         ExtendedDeploymentContext deploymentContext = null;
 
         try {
-            if (factory==null)
+            if (factory == null) {
                 factory = services.getService(ArchiveFactory.class);
+            }
 
             ContextFacade facade = (ContextFacade) context;
             File docRoot = facade.getDocRoot();
             ClassLoader classLoader = facade.getClassLoader();
             ReadableArchive archive = factory.openArchive(docRoot);
 
-            if (report==null)
+            if (report == null) {
                 report = new PlainTextActionReporter();
+            }
 
             ServerEnvironment env = services.getService(ServerEnvironment.class);
 
@@ -1996,14 +1854,14 @@
             params.virtualservers = getName();
             params.target = "server";
 
-            ExtendedDeploymentContext initialContext =
-                    new DeploymentContextImpl(report, archive, params, env);
+            ExtendedDeploymentContext initialContext = new DeploymentContextImpl(report, archive, params, env);
 
-            if (deployment==null)
+            if (deployment == null) {
                 deployment = services.getService(Deployment.class);
+            }
 
             ArchiveHandler archiveHandler = deployment.getArchiveHandler(archive);
-            if (archiveHandler==null) {
+            if (archiveHandler == null) {
                 throw new RuntimeException("Cannot find archive handler for source archive");
             }
 
@@ -2013,37 +1871,35 @@
             ApplicationInfo appInfo = deployment.get(params.name);
             ApplicationRef appRef = domain.getApplicationRefInServer(params.target, params.name);
 
-            if (appInfo!=null && appRef!=null) {
+            if (appInfo != null && appRef != null) {
                 if (appRef.getVirtualServers().contains(getName())) {
-                    throw new ConfigException(
-                            "Context with name "+params.name+" is already registered on virtual server "+getName());
+                    throw new ConfigException("Context with name " + params.name + " is already registered on virtual server " + getName());
                 } else {
                     String virtualServers = appRef.getVirtualServers();
-                    virtualServers = virtualServers + ","+getName();
+                    virtualServers = virtualServers + "," + getName();
                     params.virtualservers = virtualServers;
                     params.force = Boolean.TRUE;
-                    if (_logger.isLoggable(Level.FINE)) {
-                        _logger.log(Level.FINE, "Virtual server "+getName()+" added to context "+params.name);
+                    if (_logger.isLoggable(FINE)) {
+                        _logger.log(FINE, "Virtual server " + getName() + " added to context " + params.name);
                     }
                     return;
                 }
             }
 
-            deploymentContext = deployment.getBuilder(
-                    _logger, params, report).source(archive).archiveHandler(
-                    archiveHandler).build(initialContext);
+            deploymentContext = deployment.getBuilder(_logger, params, report).source(archive).archiveHandler(archiveHandler)
+                    .build(initialContext);
 
             Properties properties = new Properties();
             deploymentContext.getAppProps().putAll(properties);
 
             if (classLoader != null) {
-                ClassLoader parentCL = clh.createApplicationParentCL(classLoader, deploymentContext);
+                ClassLoader parentCL = classLoaderHierarchy.createApplicationParentCL(classLoader, deploymentContext);
                 ClassLoader cl = archiveHandler.getClassLoader(parentCL, deploymentContext);
                 deploymentContext.setClassLoader(cl);
             }
 
-            ApplicationConfigInfo savedAppConfig =
-                    new ApplicationConfigInfo(apps.getModule(com.sun.enterprise.config.serverbeans.Application.class, params.name));
+            ApplicationConfigInfo savedAppConfig = new ApplicationConfigInfo(
+                    apps.getModule(com.sun.enterprise.config.serverbeans.Application.class, params.name));
 
             Properties appProps = deploymentContext.getAppProps();
             String appLocation = DeploymentUtils.relativizeWithinDomainIfPossible(deploymentContext.getSource().getURI());
@@ -2057,10 +1913,10 @@
             Transaction t = deployment.prepareAppConfigChanges(deploymentContext);
             appInfo = deployment.deploy(deploymentContext);
 
-            if (appInfo!=null) {
+            if (appInfo != null) {
                 facade.setAppName(appInfo.getName());
-                if (_logger.isLoggable(Level.FINE)) {
-                    _logger.log(Level.FINE, LogFacade.VS_ADDED_CONTEXT, new Object[]{getName(), appInfo.getName()});
+                if (_logger.isLoggable(FINE)) {
+                    _logger.log(FINE, LogFacade.VS_ADDED_CONTEXT, new Object[] { getName(), appInfo.getName() });
                 }
                 deployment.registerAppInDomainXML(appInfo, deploymentContext, t);
             } else {
@@ -2080,15 +1936,14 @@
                 }
                 updateWebXml(facade, file);
             } else {
-                _logger.log(Level.SEVERE, LogFacade.APP_NOT_FOUND);
+                _logger.log(SEVERE, LogFacade.APP_NOT_FOUND);
             }
 
             ReadableArchive source = appInfo.getSource();
             UndeployCommandParameters undeployParams = new UndeployCommandParameters(params.name);
             undeployParams.origin = UndeployCommandParameters.Origin.undeploy;
             undeployParams.target = "server";
-            ExtendedDeploymentContext undeploymentContext =
-                    deployment.getBuilder(_logger, undeployParams, report).source(source).build();
+            ExtendedDeploymentContext undeploymentContext = deployment.getBuilder(_logger, undeployParams, report).source(source).build();
             deployment.undeploy(params.name, undeploymentContext);
 
             params.origin = DeployCommandParameters.Origin.load;
@@ -2097,7 +1952,7 @@
             deploymentContext = deployment.getBuilder(_logger, params, report).source(archive).build();
 
             if (classLoader != null) {
-                ClassLoader parentCL = clh.createApplicationParentCL(classLoader, deploymentContext);
+                ClassLoader parentCL = classLoaderHierarchy.createApplicationParentCL(classLoader, deploymentContext);
                 archiveHandler = deployment.getArchiveHandler(archive);
                 ClassLoader cl = archiveHandler.getClassLoader(parentCL, deploymentContext);
                 deploymentContext.setClassLoader(cl);
@@ -2109,15 +1964,15 @@
             // We can't use Deployment.enable since it doesn't take DeploymentContext with custom class loader
             deployment.updateAppEnabledAttributeInDomainXML(params.name, params.target, true);
 
-            if (_logger.isLoggable(Level.FINE)) {
-                _logger.log(Level.FINE, LogFacade.VS_ENABLED_CONTEXT, new Object[]{getName(), params.name()});
+            if (_logger.isLoggable(FINE)) {
+                _logger.log(FINE, LogFacade.VS_ENABLED_CONTEXT, new Object[] { getName(), params.name() });
             }
 
             if (delete) {
                 if (file != null) {
                     if (file.exists() && !file.delete()) {
                         String path = file.toString();
-                        _logger.log(Level.WARNING, LogFacade.UNABLE_TO_DELETE, path);
+                        _logger.log(WARNING, LogFacade.UNABLE_TO_DELETE, path);
                     }
                 }
             }
@@ -2133,7 +1988,7 @@
                     wm.setDefaultWebXml(config.getDefaultWebXml());
                 }
             } else {
-                throw new ConfigException("Deployed app not found "+contextRoot);
+                throw new ConfigException("Deployed app not found " + contextRoot);
             }
 
             if (deploymentContext != null) {
@@ -2141,7 +1996,7 @@
             }
 
         } catch (Exception ex) {
-            if (deployment!=null && deploymentContext!=null) {
+            if (deployment != null && deploymentContext != null) {
                 deploymentContext.clean();
             }
             throw new GlassFishException(ex);
@@ -2150,15 +2005,15 @@
     }
 
     /**
-     * Stops the given <tt>context</tt> and removes it from this
-     * <tt>VirtualServer</tt>.
+     * Stops the given <tt>context</tt> and removes it from this <tt>VirtualServer</tt>.
      */
+    @Override
     public void removeContext(Context context) throws GlassFishException {
         ActionReport report = services.getService(ActionReport.class, "plain");
         Deployment deployment = services.getService(Deployment.class);
         String name;
         if (context instanceof ContextFacade) {
-            name = ((ContextFacade)context).getAppName();
+            name = ((ContextFacade) context).getAppName();
         } else {
             name = context.getPath();
         }
@@ -2188,62 +2043,59 @@
             deployment.undeploy(name, deploymentContext);
             deployment.unregisterAppFromDomainXML(name, "server");
         } catch (IOException e) {
-            _logger.log(Level.SEVERE, LogFacade.REMOVE_CONTEXT_ERROR, e);
+            _logger.log(SEVERE, LogFacade.REMOVE_CONTEXT_ERROR, e);
             report.setActionExitCode(ActionReport.ExitCode.FAILURE);
             throw new GlassFishException("Cannot create context for undeployment ", e);
         } catch (TransactionFailure e) {
             throw new GlassFishException(e);
         } finally {
-            if (deploymentContext!=null) {
+            if (deploymentContext != null) {
                 deploymentContext.clean();
             }
         }
 
-        if (_logger.isLoggable(Level.FINE)) {
-            _logger.log(Level.FINE, LogFacade.REMOVED_CONTEXT, name);
+        if (_logger.isLoggable(FINE)) {
+            _logger.log(FINE, LogFacade.REMOVED_CONTEXT, name);
         }
     }
 
-
     /**
      * Finds the <tt>Context</tt> registered at the given context root.
      */
+    @Override
     public Context getContext(String contextRoot) {
         if (!contextRoot.startsWith("/")) {
-            contextRoot = "/"+contextRoot;
+            contextRoot = "/" + contextRoot;
         }
-        return (Context)findChild(contextRoot);
+        return (Context) findChild(contextRoot);
     }
 
     /**
-     * Gets the collection of <tt>Context</tt> instances registered with
-     * this <tt>VirtualServer</tt>.
+     * Gets the collection of <tt>Context</tt> instances registered with this <tt>VirtualServer</tt>.
      */
+    @Override
     public Collection<Context> getContexts() {
-        Collection<Context> ctxs = new ArrayList<Context>();
+        Collection<Context> ctxs = new ArrayList<>();
         for (Container container : findChildren()) {
             if (container instanceof Context) {
-                ctxs.add((Context)container);
+                ctxs.add((Context) container);
             }
         }
         return ctxs;
     }
 
     /**
-     * Reconfigures this <tt>VirtualServer</tt> with the given
-     * configuration.
+     * Reconfigures this <tt>VirtualServer</tt> with the given configuration.
      *
-     * <p>In order for the given configuration to take effect, this
-     * <tt>VirtualServer</tt> may be stopped and restarted.
+     * <p>
+     * In order for the given configuration to take effect, this <tt>VirtualServer</tt> may be stopped and restarted.
      */
-    public void setConfig(VirtualServerConfig config)
-        throws ConfigException {
+    @Override
+    public void setConfig(VirtualServerConfig config) throws ConfigException {
 
         this.config = config;
         configureSingleSignOn(config.isSsoEnabled(),
-                Globals.getDefaultHabitat().<PEWebContainerFeatureFactoryImpl>getService(
-                PEWebContainerFeatureFactoryImpl.class),
-                false);
+                Globals.getDefaultHabitat().<PEWebContainerFeatureFactoryImpl>getService(PEWebContainerFeatureFactoryImpl.class), false);
         if (config.isAccessLoggingEnabled()) {
             enableAccessLogging();
         } else {
@@ -2261,6 +2113,7 @@
     /**
      * Gets the current configuration of this <tt>VirtualServer</tt>.
      */
+    @Override
     public VirtualServerConfig getConfig() {
         return config;
     }
@@ -2268,9 +2121,9 @@
     @Override
     public synchronized void stop() throws LifecycleException {
         if (fileLoggerHandler != null) {
-           _logger.removeHandler(fileLoggerHandler);
-           close(fileLoggerHandler);
-           fileLoggerHandler = null;
+            _logger.removeHandler(fileLoggerHandler);
+            close(fileLoggerHandler);
+            fileLoggerHandler = null;
         }
         setLogger(_logger, "INFO");
 
@@ -2278,7 +2131,6 @@
     }
 
     public void updateWebXml(ContextFacade facade, File file) throws Exception {
-
         Map<String, String> servlets = facade.getAddedServlets();
         Map<String, String[]> mappings = facade.getServletMappings();
         List<String> listeners = facade.getListeners();
@@ -2287,8 +2139,8 @@
         Map<String, String> urlPatternFilterMappings = facade.getUrlPatternFilterMappings();
 
         if (!filters.isEmpty() || !listeners.isEmpty() || !servlets.isEmpty()) {
-            if (_logger.isLoggable(Level.FINE)) {
-                _logger.log(Level.FINE, LogFacade.MODIFYING_WEB_XML, file.getAbsolutePath());
+            if (_logger.isLoggable(FINE)) {
+                _logger.log(FINE, MODIFYING_WEB_XML, file.getAbsolutePath());
             }
 
             DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
@@ -2317,12 +2169,11 @@
             // Update <filter>
             for (Map.Entry entry : filters.entrySet()) {
                 NodeList filterList = doc.getElementsByTagName("filter-name");
-                for (int i=0; i<filterList.getLength(); i++) {
+                for (int i = 0; i < filterList.getLength(); i++) {
                     Node filterNode = filterList.item(i);
-                    if (entry.getKey().equals(filterNode.getTextContent()) &&
-                            filterNode.getParentNode().getNodeName().equals("filter")) {
+                    if (entry.getKey().equals(filterNode.getTextContent()) && filterNode.getParentNode().getNodeName().equals("filter")) {
                         NodeList children = filterNode.getParentNode().getChildNodes();
-                        for (int j=0; j<children.getLength(); j++) {
+                        for (int j = 0; j < children.getLength(); j++) {
                             Node filterClass = children.item(j);
                             if (filterClass.getNodeName().equals("filter-class")) {
                                 // If a filter with the given filter-name is already defined,
@@ -2342,8 +2193,7 @@
                     Element filterClass = doc.createElement("filter-class");
                     filterClass.setTextContent(entry.getValue().toString());
                     filter.appendChild(filterClass);
-                    Map<String, String> initParams =
-                            facade.getFilterRegistration(entry.getKey().toString()).getInitParameters();
+                    Map<String, String> initParams = facade.getFilterRegistration(entry.getKey().toString()).getInitParameters();
                     if ((initParams != null) && (!initParams.isEmpty())) {
                         Element initParam = doc.createElement("init-param");
                         for (Map.Entry param : initParams.entrySet()) {
@@ -2388,12 +2238,12 @@
             // Update <servlet>
             for (Map.Entry entry : servlets.entrySet()) {
                 NodeList servletList = doc.getElementsByTagName("servlet-name");
-                for (int i=0; i<servletList.getLength(); i++) {
+                for (int i = 0; i < servletList.getLength(); i++) {
                     Node servletNode = servletList.item(i);
-                    if (entry.getKey().equals(servletNode.getTextContent()) &&
-                            servletNode.getParentNode().getNodeName().equals("servlet")) {
+                    if (entry.getKey().equals(servletNode.getTextContent())
+                            && servletNode.getParentNode().getNodeName().equals("servlet")) {
                         NodeList children = servletNode.getParentNode().getChildNodes();
-                        for (int j=0; j<children.getLength(); j++) {
+                        for (int j = 0; j < children.getLength(); j++) {
                             Node servletClass = children.item(j);
                             if (servletClass.getNodeName().equals("servlet-class")) {
                                 // If a servlet with the given servlet-name is already defined,
@@ -2413,8 +2263,7 @@
                     Element servletClass = doc.createElement("servlet-class");
                     servletClass.setTextContent(entry.getValue().toString());
                     servlet.appendChild(servletClass);
-                    Map<String, String> initParams =
-                        facade.getServletRegistration(entry.getKey().toString()).getInitParameters();
+                    Map<String, String> initParams = facade.getServletRegistration(entry.getKey().toString()).getInitParameters();
                     if ((initParams != null) && (!initParams.isEmpty())) {
                         Element initParam = doc.createElement("init-param");
                         for (Map.Entry param : initParams.entrySet()) {
@@ -2436,12 +2285,12 @@
             // Update <servlet-mapping>
             for (Map.Entry mapping : mappings.entrySet()) {
                 NodeList servletList = doc.getElementsByTagName("servlet-name");
-                for (int i=0; i<servletList.getLength(); i++) {
+                for (int i = 0; i < servletList.getLength(); i++) {
                     Node servletNode = servletList.item(i);
-                    if (mapping.getKey().equals(servletNode.getTextContent()) &&
-                            servletNode.getParentNode().getNodeName().equals("servlet-mapping")) {
+                    if (mapping.getKey().equals(servletNode.getTextContent())
+                            && servletNode.getParentNode().getNodeName().equals("servlet-mapping")) {
                         NodeList children = servletNode.getParentNode().getChildNodes();
-                        for (int j=0; j<children.getLength(); j++) {
+                        for (int j = 0; j < children.getLength(); j++) {
                             Node urlPattern = children.item(j);
                             if (urlPattern.getNodeName().equals("url-pattern")) {
                                 // If any of the specified URL patterns are already mapped to a different Servlet,
@@ -2477,7 +2326,7 @@
             Transformer transformer = TransformerFactory.newInstance().newTransformer();
             transformer.setOutputProperty(OutputKeys.INDENT, "yes");
 
-            if (file!=null) {
+            if (file != null) {
                 DOMSource src = new DOMSource(doc);
                 StreamResult result = new StreamResult(file);
                 transformer.transform(src, result);
@@ -2486,18 +2335,13 @@
         }
     }
 
-
     private List<NetworkListener> getGrizzlyNetworkListeners() {
-        List<String> listenerList = StringUtils.parseStringList(
-                vsBean.getNetworkListeners(), ",");
-        String[] listeners = (listenerList != null) ?
-                listenerList.toArray(new String[listenerList.size()]) :
-                new String[0];
-        List<NetworkListener> networkListeners = new ArrayList<NetworkListener>();
+        List<String> listenerList = StringUtils.parseStringList(vsBean.getNetworkListeners(), ",");
+        String[] listeners = (listenerList != null) ? listenerList.toArray(new String[listenerList.size()]) : new String[0];
+        List<NetworkListener> networkListeners = new ArrayList<>();
 
         for (String listener : listeners) {
-            for (NetworkListener networkListener :
-                    serverConfig.getNetworkConfig().getNetworkListeners().getNetworkListener()) {
+            for (NetworkListener networkListener : serverConfig.getNetworkConfig().getNetworkListeners().getNetworkListener()) {
                 if (networkListener.getName().equals(listener)) {
                     networkListeners.add(networkListener);
                 }
@@ -2512,36 +2356,34 @@
         for (final NetworkListener listener : getGrizzlyNetworkListeners()) {
             final GrizzlyProxy proxy = (GrizzlyProxy) grizzlyService.lookupNetworkProxy(listener);
             if (proxy != null) {
-                 GenericGrizzlyListener grizzlyListener = (GenericGrizzlyListener) proxy.getUnderlyingListener();
-                 List<HttpCodecFilter> codecFilters = grizzlyListener.getFilters(HttpCodecFilter.class);
-                 if (codecFilters != null && !codecFilters.isEmpty()) {
-                     for (HttpCodecFilter codecFilter : codecFilters) {
-                         HttpProbe[] probes = codecFilter.getMonitoringConfig().getProbes();
-                         if (probes != null) {
-                             for (HttpProbe probe : probes) {
-                                 if (probe instanceof HttpProbeImpl) {
-                                     httpProbes.add((HttpProbeImpl)probe);
-                                 }
-                             }
-                         }
-                     }
-                 }
+                GenericGrizzlyListener grizzlyListener = (GenericGrizzlyListener) proxy.getUnderlyingListener();
+                List<HttpCodecFilter> codecFilters = grizzlyListener.getFilters(HttpCodecFilter.class);
+                if (codecFilters != null && !codecFilters.isEmpty()) {
+                    for (HttpCodecFilter codecFilter : codecFilters) {
+                        HttpProbe[] probes = codecFilter.getMonitoringConfig().getProbes();
+                        if (probes != null) {
+                            for (HttpProbe probe : probes) {
+                                if (probe instanceof HttpProbeImpl) {
+                                    httpProbes.add((HttpProbeImpl) probe);
+                                }
+                            }
+                        }
+                    }
+                }
             }
         }
 
         return httpProbes;
     }
 
-
     // ---------------------------------------------------------- Nested Classes
 
-
     private final class HttpProbeImpl extends HttpProbe.Adapter {
 
-        boolean accessLoggingEnabled = false;
-        NetworkListener listener = null;
+        boolean accessLoggingEnabled;
+        NetworkListener listener;
 
-        public HttpProbeImpl(NetworkListener listener, boolean accessLoggingEnabled)  {
+        public HttpProbeImpl(NetworkListener listener, boolean accessLoggingEnabled) {
             this.listener = listener;
             this.accessLoggingEnabled = accessLoggingEnabled;
         }
@@ -2565,32 +2407,30 @@
                     // 400 should be hardcoded since the response status isn't available for bad requests
                     responsePacket.setStatus(HttpStatus.BAD_REQUEST_400);
 
-                    org.glassfish.grizzly.http.server.Request request = org.glassfish.grizzly.http.server.Request.create();
-//                    org.glassfish.grizzly.http.server.Response response = org.glassfish.grizzly.http.server.Response.create();
-                    org.glassfish.grizzly.http.server.Response response = request.getResponse();
+                    org.glassfish.grizzly.http.server.Request grizzlyRequest = org.glassfish.grizzly.http.server.Request.create();
+                    org.glassfish.grizzly.http.server.Response grizzlyResponse = grizzlyRequest.getResponse();
 
-//                    request.initialize(response, requestPacket, FilterChainContext.create(connection), null);
-                    request.initialize(/*response,*/ requestPacket, FilterChainContext.create(connection), null);
-                    response.initialize(request, responsePacket, FilterChainContext.create(connection), null, null);
+                    grizzlyRequest.initialize(requestPacket, FilterChainContext.create(connection), null);
+                    grizzlyResponse.initialize(grizzlyRequest, responsePacket, FilterChainContext.create(connection), null, null);
 
-                    Response res = new Response();
-                    res.setCoyoteResponse(response);
+                    Response catalinaResponse = new Response();
+                    catalinaResponse.setCoyoteResponse(grizzlyResponse);
 
                     WebConnector connector = webContainer.getConnectorMap().get(listener.getName());
                     if (connector != null) {
-                        Request req = new Request();
-                        req.setCoyoteRequest(request);
-                        req.setConnector(connector);
+                        Request catalinaRequest = new Request();
+                        catalinaRequest.setGrizzlyRequest(grizzlyRequest);
+                        catalinaRequest.setConnector(connector);
                         try {
-                            accessLogValve.postInvoke(req, res);
+                            accessLogValve.postInvoke(catalinaRequest, catalinaResponse);
                         } catch (IOException ex) {
-                            _logger.log(Level.SEVERE, LogFacade.UNABLE_RECONFIGURE_ACCESS_LOG, ex);
+                            _logger.log(SEVERE, UNABLE_RECONFIGURE_ACCESS_LOG, ex);
                         }
                     } else {
-                        _logger.log(Level.SEVERE, LogFacade.UNABLE_RECONFIGURE_ACCESS_LOG);
+                        _logger.log(SEVERE, UNABLE_RECONFIGURE_ACCESS_LOG);
                     }
                 } else {
-                    _logger.log(Level.SEVERE, LogFacade.UNABLE_RECONFIGURE_ACCESS_LOG);
+                    _logger.log(SEVERE, UNABLE_RECONFIGURE_ACCESS_LOG);
                 }
             }
         }
@@ -2598,5 +2438,3 @@
     }
 
 }
-
-