You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/01/24 13:21:27 UTC

[tomcat] branch 8.5.x updated (e9403a45ba -> 353306175b)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


    from e9403a45ba Code cleanup (format). No functional change.
     new 8f55a7bc9c Code cleanup (format). No functional change.
     new 353306175b Add ALv2 headers

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/catalina/core/AccessLogAdapter.java |    2 +-
 .../apache/catalina/core/ApplicationContext.java   |  180 +--
 .../catalina/core/ApplicationContextFacade.java    |  329 ++--
 .../catalina/core/ApplicationDispatcher.java       |  332 ++--
 .../catalina/core/ApplicationFilterChain.java      |  118 +-
 .../catalina/core/ApplicationFilterConfig.java     |  131 +-
 .../catalina/core/ApplicationFilterFactory.java    |   75 +-
 .../core/ApplicationFilterRegistration.java        |   21 +-
 .../catalina/core/ApplicationHttpRequest.java      |  164 +-
 .../catalina/core/ApplicationHttpResponse.java     |   59 +-
 .../catalina/core/ApplicationMappingImpl.java      |    3 +-
 .../catalina/core/ApplicationMappingMatch.java     |    9 +-
 java/org/apache/catalina/core/ApplicationPart.java |   13 +-
 .../catalina/core/ApplicationPushBuilder.java      |   32 +-
 .../apache/catalina/core/ApplicationRequest.java   |   50 +-
 .../apache/catalina/core/ApplicationResponse.java  |   32 +-
 .../core/ApplicationServletRegistration.java       |   22 +-
 .../core/ApplicationSessionCookieConfig.java       |   58 +-
 .../apache/catalina/core/AprLifecycleListener.java |  101 +-
 .../org/apache/catalina/core/AsyncContextImpl.java |  103 +-
 .../apache/catalina/core/AsyncListenerWrapper.java |    3 +-
 java/org/apache/catalina/core/ContainerBase.java   |  360 ++---
 .../catalina/core/DefaultInstanceManager.java      |  284 ++--
 .../apache/catalina/core/JniLifecycleListener.java |   12 +-
 .../core/JreMemoryLeakPreventionListener.java      |  340 ++--
 .../catalina/core/NamingContextListener.java       |  173 +--
 java/org/apache/catalina/core/StandardContext.java | 1636 ++++++++------------
 .../apache/catalina/core/StandardContextValve.java |   27 +-
 java/org/apache/catalina/core/StandardEngine.java  |   98 +-
 .../apache/catalina/core/StandardEngineValve.java  |   20 +-
 java/org/apache/catalina/core/StandardHost.java    |  176 +--
 .../apache/catalina/core/StandardHostValve.java    |   81 +-
 .../org/apache/catalina/core/StandardPipeline.java |   93 +-
 java/org/apache/catalina/core/StandardServer.java  |  122 +-
 java/org/apache/catalina/core/StandardService.java |   91 +-
 .../catalina/core/StandardThreadExecutor.java      |   36 +-
 java/org/apache/catalina/core/StandardWrapper.java |  445 +++---
 .../catalina/core/StandardWrapperFacade.java       |    4 +-
 .../apache/catalina/core/StandardWrapperValve.java |  119 +-
 .../core/ThreadLocalLeakPreventionListener.java    |   70 +-
 res/ide-support/eclipse/clean-up-asf-tomcat.xml    |   16 +
 res/ide-support/eclipse/formatting-asf-tomcat.xml  |   16 +
 42 files changed, 2427 insertions(+), 3629 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 02/02: Add ALv2 headers

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 353306175b031a9c7595cbea9f06958ee48d7ddc
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Jan 24 13:20:30 2023 +0000

    Add ALv2 headers
---
 res/ide-support/eclipse/clean-up-asf-tomcat.xml   | 16 ++++++++++++++++
 res/ide-support/eclipse/formatting-asf-tomcat.xml | 16 ++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/res/ide-support/eclipse/clean-up-asf-tomcat.xml b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
index f56c6fe4d2..4a5b69aa25 100644
--- a/res/ide-support/eclipse/clean-up-asf-tomcat.xml
+++ b/res/ide-support/eclipse/clean-up-asf-tomcat.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
 <profiles version="2">
     <profile kind="CleanUpProfile" name="asf-tomcat" version="2">
         <setting id="cleanup.array_with_curly" value="false"/>
diff --git a/res/ide-support/eclipse/formatting-asf-tomcat.xml b/res/ide-support/eclipse/formatting-asf-tomcat.xml
index 8327af9885..71f085b69d 100644
--- a/res/ide-support/eclipse/formatting-asf-tomcat.xml
+++ b/res/ide-support/eclipse/formatting-asf-tomcat.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
 <profiles version="22">
     <profile kind="CodeFormatterProfile" name="asf-tomcat" version="22">
         <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat] 01/02: Code cleanup (format). No functional change.

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 8f55a7bc9c2a94efe3658fc1ae01f2bf01bcf102
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Jan 24 13:13:32 2023 +0000

    Code cleanup (format). No functional change.
---
 .../org/apache/catalina/core/AccessLogAdapter.java |    2 +-
 .../apache/catalina/core/ApplicationContext.java   |  180 +--
 .../catalina/core/ApplicationContextFacade.java    |  329 ++--
 .../catalina/core/ApplicationDispatcher.java       |  332 ++--
 .../catalina/core/ApplicationFilterChain.java      |  118 +-
 .../catalina/core/ApplicationFilterConfig.java     |  131 +-
 .../catalina/core/ApplicationFilterFactory.java    |   75 +-
 .../core/ApplicationFilterRegistration.java        |   21 +-
 .../catalina/core/ApplicationHttpRequest.java      |  164 +-
 .../catalina/core/ApplicationHttpResponse.java     |   59 +-
 .../catalina/core/ApplicationMappingImpl.java      |    3 +-
 .../catalina/core/ApplicationMappingMatch.java     |    9 +-
 java/org/apache/catalina/core/ApplicationPart.java |   13 +-
 .../catalina/core/ApplicationPushBuilder.java      |   32 +-
 .../apache/catalina/core/ApplicationRequest.java   |   50 +-
 .../apache/catalina/core/ApplicationResponse.java  |   32 +-
 .../core/ApplicationServletRegistration.java       |   22 +-
 .../core/ApplicationSessionCookieConfig.java       |   58 +-
 .../apache/catalina/core/AprLifecycleListener.java |  101 +-
 .../org/apache/catalina/core/AsyncContextImpl.java |  103 +-
 .../apache/catalina/core/AsyncListenerWrapper.java |    3 +-
 java/org/apache/catalina/core/ContainerBase.java   |  360 ++---
 .../catalina/core/DefaultInstanceManager.java      |  284 ++--
 .../apache/catalina/core/JniLifecycleListener.java |   12 +-
 .../core/JreMemoryLeakPreventionListener.java      |  340 ++--
 .../catalina/core/NamingContextListener.java       |  173 +--
 java/org/apache/catalina/core/StandardContext.java | 1636 ++++++++------------
 .../apache/catalina/core/StandardContextValve.java |   27 +-
 java/org/apache/catalina/core/StandardEngine.java  |   98 +-
 .../apache/catalina/core/StandardEngineValve.java  |   20 +-
 java/org/apache/catalina/core/StandardHost.java    |  176 +--
 .../apache/catalina/core/StandardHostValve.java    |   81 +-
 .../org/apache/catalina/core/StandardPipeline.java |   93 +-
 java/org/apache/catalina/core/StandardServer.java  |  122 +-
 java/org/apache/catalina/core/StandardService.java |   91 +-
 .../catalina/core/StandardThreadExecutor.java      |   36 +-
 java/org/apache/catalina/core/StandardWrapper.java |  445 +++---
 .../catalina/core/StandardWrapperFacade.java       |    4 +-
 .../apache/catalina/core/StandardWrapperValve.java |  119 +-
 .../core/ThreadLocalLeakPreventionListener.java    |   70 +-
 40 files changed, 2395 insertions(+), 3629 deletions(-)

diff --git a/java/org/apache/catalina/core/AccessLogAdapter.java b/java/org/apache/catalina/core/AccessLogAdapter.java
index e3705664d1..8a107a4409 100644
--- a/java/org/apache/catalina/core/AccessLogAdapter.java
+++ b/java/org/apache/catalina/core/AccessLogAdapter.java
@@ -44,7 +44,7 @@ public class AccessLogAdapter implements AccessLog {
 
     @Override
     public void log(Request request, Response response, long time) {
-        for (AccessLog log: logs) {
+        for (AccessLog log : logs) {
             log.log(request, response, time);
         }
     }
diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java
index 6d5615ddd1..a6d44cc298 100644
--- a/java/org/apache/catalina/core/ApplicationContext.java
+++ b/java/org/apache/catalina/core/ApplicationContext.java
@@ -80,9 +80,8 @@ import org.apache.tomcat.util.res.StringManager;
 
 
 /**
- * Standard implementation of <code>ServletContext</code> that represents
- * a web application's execution environment.  An instance of this class is
- * associated with each instance of <code>StandardContext</code>.
+ * Standard implementation of <code>ServletContext</code> that represents a web application's execution environment. An
+ * instance of this class is associated with each instance of <code>StandardContext</code>.
  *
  * @author Craig R. McClanahan
  * @author Remy Maucherat
@@ -96,8 +95,8 @@ public class ApplicationContext implements ServletContext {
     static {
         STRICT_SERVLET_COMPLIANCE = Globals.STRICT_SERVLET_COMPLIANCE;
 
-        String requireSlash = System.getProperty(
-                "org.apache.catalina.core.ApplicationContext.GET_RESOURCE_REQUIRE_SLASH");
+        String requireSlash = System
+                .getProperty("org.apache.catalina.core.ApplicationContext.GET_RESOURCE_REQUIRE_SLASH");
         if (requireSlash == null) {
             GET_RESOURCE_REQUIRE_SLASH = STRICT_SERVLET_COMPLIANCE;
         } else {
@@ -109,8 +108,7 @@ public class ApplicationContext implements ServletContext {
     // ----------------------------------------------------------- Constructors
 
     /**
-     * Construct a new instance of this class, associated with the specified
-     * Context instance.
+     * Construct a new instance of this class, associated with the specified Context instance.
      *
      * @param context The associated Context instance
      */
@@ -131,13 +129,13 @@ public class ApplicationContext implements ServletContext {
     /**
      * The context attributes for this context.
      */
-    protected Map<String,Object> attributes = new ConcurrentHashMap<>();
+    protected Map<String, Object> attributes = new ConcurrentHashMap<>();
 
 
     /**
      * List of read only attributes for this context.
      */
-    private final Map<String,String> readOnlyAttributes = new ConcurrentHashMap<>();
+    private final Map<String, String> readOnlyAttributes = new ConcurrentHashMap<>();
 
 
     /**
@@ -173,7 +171,7 @@ public class ApplicationContext implements ServletContext {
     /**
      * The merged context initialization parameters for this Context.
      */
-    private final ConcurrentMap<String,String> parameters = new ConcurrentHashMap<>();
+    private final ConcurrentMap<String, String> parameters = new ConcurrentHashMap<>();
 
 
     /**
@@ -201,9 +199,8 @@ public class ApplicationContext implements ServletContext {
     private Set<SessionTrackingMode> supportedSessionTrackingModes = null;
 
     /**
-     * Flag that indicates if a new {@link ServletContextListener} may be added
-     * to the application. Once the first {@link ServletContextListener} is
-     * called, no more may be added.
+     * Flag that indicates if a new {@link ServletContextListener} may be added to the application. Once the first
+     * {@link ServletContextListener} is called, no more may be added.
      */
     private boolean newServletContextListenerAllowed = true;
 
@@ -249,9 +246,9 @@ public class ApplicationContext implements ServletContext {
                     uri = uri.substring(0, i);
                 }
                 // Note: This could be more efficient with a dedicated Mapper
-                //       method but such an implementation would require some
-                //       refactoring of the Mapper to avoid copy/paste of
-                //       existing code.
+                // method but such an implementation would require some
+                // refactoring of the Mapper to avoid copy/paste of
+                // existing code.
                 MessageBytes hostMB = MessageBytes.newInstance();
                 hostMB.setString(host.getName());
 
@@ -294,8 +291,7 @@ public class ApplicationContext implements ServletContext {
     public String getInitParameter(final String name) {
         // Special handling for XML settings as the context setting must
         // always override anything that might have been set by an application.
-        if (Globals.JASPER_XML_VALIDATION_TLD_INIT_PARAM.equals(name) &&
-                context.getTldValidation()) {
+        if (Globals.JASPER_XML_VALIDATION_TLD_INIT_PARAM.equals(name) && context.getTldValidation()) {
             return "true";
         }
         if (Globals.JASPER_XML_BLOCK_EXTERNAL_INIT_PARAM.equals(name)) {
@@ -336,8 +332,7 @@ public class ApplicationContext implements ServletContext {
 
 
     /**
-     * Return the MIME type of the specified file, or <code>null</code> if
-     * the MIME type cannot be determined.
+     * Return the MIME type of the specified file, or <code>null</code> if the MIME type cannot be determined.
      *
      * @param file Filename for which to identify a MIME type
      */
@@ -361,8 +356,7 @@ public class ApplicationContext implements ServletContext {
 
 
     /**
-     * Return a <code>RequestDispatcher</code> object that acts as a
-     * wrapper for the named servlet.
+     * Return a <code>RequestDispatcher</code> object that acts as a wrapper for the named servlet.
      *
      * @param name Name of the servlet for which a dispatcher is requested
      */
@@ -400,8 +394,7 @@ public class ApplicationContext implements ServletContext {
             return null;
         }
         if (!path.startsWith("/")) {
-            throw new IllegalArgumentException(
-                    sm.getString("applicationContext.requestDispatcher.iae", path));
+            throw new IllegalArgumentException(sm.getString("applicationContext.requestDispatcher.iae", path));
         }
 
         // Same processing order as InputBuffer / CoyoteAdapter
@@ -435,8 +428,7 @@ public class ApplicationContext implements ServletContext {
             // Security check to catch attempts to encode /../ sequences
             normalizedUri = RequestUtil.normalize(decodedUri);
             if (!decodedUri.equals(normalizedUri)) {
-                getContext().getLogger().warn(
-                        sm.getString("applicationContext.illegalDispatchPath", path),
+                getContext().getLogger().warn(sm.getString("applicationContext.illegalDispatchPath", path),
                         new IllegalArgumentException());
                 return null;
             }
@@ -485,8 +477,7 @@ public class ApplicationContext implements ServletContext {
             ApplicationMappingImpl mapping = new ApplicationMapping(mappingData).getHttpServletMapping();
 
             // Construct a RequestDispatcher to process this request
-            return new ApplicationDispatcher(wrapper, uri, wrapperPath, pathInfo,
-                    queryString, mapping, null);
+            return new ApplicationDispatcher(wrapper, uri, wrapperPath, pathInfo, queryString, mapping, null);
         } finally {
             // Recycle thread local data at the end of the request so references
             // are not held to a completed request as there is potential for
@@ -534,8 +525,7 @@ public class ApplicationContext implements ServletContext {
         String validatedPath = validateResourcePath(path, !GET_RESOURCE_REQUIRE_SLASH);
 
         if (validatedPath == null) {
-            throw new MalformedURLException(
-                    sm.getString("applicationContext.requestDispatcher.iae", path));
+            throw new MalformedURLException(sm.getString("applicationContext.requestDispatcher.iae", path));
         }
 
         WebResourceRoot resources = context.getResources();
@@ -566,8 +556,7 @@ public class ApplicationContext implements ServletContext {
 
 
     /*
-     * Returns null if the input path is not valid or a path that will be
-     * acceptable to resources.getResource().
+     * Returns null if the input path is not valid or a path that will be acceptable to resources.getResource().
      */
     private String validateResourcePath(String path, boolean addMissingInitialSlash) {
         if (path == null) {
@@ -594,7 +583,7 @@ public class ApplicationContext implements ServletContext {
             return null;
         }
         if (!path.startsWith("/")) {
-            throw new IllegalArgumentException (sm.getString("applicationContext.resourcePaths.iae", path));
+            throw new IllegalArgumentException(sm.getString("applicationContext.resourcePaths.iae", path));
         }
 
         WebResourceRoot resources = context.getResources();
@@ -665,7 +654,7 @@ public class ApplicationContext implements ServletContext {
 
         // Remove the specified attribute
         // Check for read only attribute
-        if (readOnlyAttributes.containsKey(name)){
+        if (readOnlyAttributes.containsKey(name)) {
             return;
         }
         value = attributes.remove(name);
@@ -678,8 +667,7 @@ public class ApplicationContext implements ServletContext {
         if ((listeners == null) || (listeners.length == 0)) {
             return;
         }
-        ServletContextAttributeEvent event = new ServletContextAttributeEvent(
-                context.getServletContext(), name, value);
+        ServletContextAttributeEvent event = new ServletContextAttributeEvent(context.getServletContext(), name, value);
         for (Object obj : listeners) {
             if (!(obj instanceof ServletContextAttributeListener)) {
                 continue;
@@ -775,18 +763,16 @@ public class ApplicationContext implements ServletContext {
 
 
     @Override
-    public FilterRegistration.Dynamic addFilter(String filterName,
-            Class<? extends Filter> filterClass) {
+    public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass) {
         return addFilter(filterName, filterClass.getName(), null);
     }
 
 
-    private FilterRegistration.Dynamic addFilter(String filterName,
-            String filterClass, Filter filter) throws IllegalStateException {
+    private FilterRegistration.Dynamic addFilter(String filterName, String filterClass, Filter filter)
+            throws IllegalStateException {
 
         if (filterName == null || filterName.equals("")) {
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationContext.invalidFilterName", filterName));
+            throw new IllegalArgumentException(sm.getString("applicationContext.invalidFilterName", filterName));
         }
 
         // TODO Spec breaking enhancement to ignore this restriction
@@ -801,8 +787,7 @@ public class ApplicationContext implements ServletContext {
             filterDef.setFilterName(filterName);
             context.addFilterDef(filterDef);
         } else {
-            if (filterDef.getFilterName() != null &&
-                    filterDef.getFilterClass() != null) {
+            if (filterDef.getFilterName() != null && filterDef.getFilterClass() != null) {
                 return null;
             }
         }
@@ -856,8 +841,7 @@ public class ApplicationContext implements ServletContext {
 
 
     @Override
-    public ServletRegistration.Dynamic addServlet(String servletName,
-            Class<? extends Servlet> servletClass) {
+    public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) {
         return addServlet(servletName, servletClass.getName(), null, null);
     }
 
@@ -866,12 +850,11 @@ public class ApplicationContext implements ServletContext {
 
         // jspName is validated in addServlet()
         if (jspFile == null || !jspFile.startsWith("/")) {
-            throw new IllegalArgumentException(
-                    sm.getString("applicationContext.addJspFile.iae", jspFile));
+            throw new IllegalArgumentException(sm.getString("applicationContext.addJspFile.iae", jspFile));
         }
 
         String jspServletClassName = null;
-        Map<String,String> jspFileInitParams = new HashMap<>();
+        Map<String, String> jspFileInitParams = new HashMap<>();
 
         Wrapper jspServlet = (Wrapper) context.findChild("jsp");
 
@@ -897,12 +880,11 @@ public class ApplicationContext implements ServletContext {
     }
 
 
-    private ServletRegistration.Dynamic addServlet(String servletName, String servletClass,
-            Servlet servlet, Map<String,String> initParams) throws IllegalStateException {
+    private ServletRegistration.Dynamic addServlet(String servletName, String servletClass, Servlet servlet,
+            Map<String, String> initParams) throws IllegalStateException {
 
         if (servletName == null || servletName.equals("")) {
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationContext.invalidServletName", servletName));
+            throw new IllegalArgumentException(sm.getString("applicationContext.invalidServletName", servletName));
         }
 
         // TODO Spec breaking enhancement to ignore this restriction
@@ -917,8 +899,7 @@ public class ApplicationContext implements ServletContext {
             wrapper.setName(servletName);
             context.addChild(wrapper);
         } else {
-            if (wrapper.getName() != null &&
-                    wrapper.getServletClass() != null) {
+            if (wrapper.getName() != null && wrapper.getServletClass() != null) {
                 if (wrapper.isOverridable()) {
                     wrapper.setOverridable(false);
                 } else {
@@ -943,13 +924,12 @@ public class ApplicationContext implements ServletContext {
         }
 
         if (initParams != null) {
-            for (Map.Entry<String, String> initParam: initParams.entrySet()) {
+            for (Map.Entry<String, String> initParam : initParams.entrySet()) {
                 wrapper.addInitParameter(initParam.getKey(), initParam.getValue());
             }
         }
 
-        ServletRegistration.Dynamic registration =
-                new ApplicationServletRegistration(wrapper, context);
+        ServletRegistration.Dynamic registration = new ApplicationServletRegistration(wrapper, context);
         if (annotation != null) {
             registration.setServletSecurity(new ServletSecurityElement(annotation));
         }
@@ -1036,8 +1016,7 @@ public class ApplicationContext implements ServletContext {
         // Check that only supported tracking modes have been requested
         for (SessionTrackingMode sessionTrackingMode : sessionTrackingModes) {
             if (!supportedSessionTrackingModes.contains(sessionTrackingMode)) {
-                throw new IllegalArgumentException(sm.getString(
-                        "applicationContext.setSessionTracking.iae.invalid",
+                throw new IllegalArgumentException(sm.getString("applicationContext.setSessionTracking.iae.invalid",
                         sessionTrackingMode.toString(), getContextPath()));
             }
         }
@@ -1045,9 +1024,8 @@ public class ApplicationContext implements ServletContext {
         // Check SSL has not be configured with anything else
         if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) {
             if (sessionTrackingModes.size() > 1) {
-                throw new IllegalArgumentException(sm.getString(
-                        "applicationContext.setSessionTracking.iae.ssl",
-                        getContextPath()));
+                throw new IllegalArgumentException(
+                        sm.getString("applicationContext.setSessionTracking.iae.ssl", getContextPath()));
             }
         }
 
@@ -1072,9 +1050,8 @@ public class ApplicationContext implements ServletContext {
         try {
             listener = createListener(listenerClass);
         } catch (ServletException e) {
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationContext.addListener.iae.init",
-                    listenerClass.getName()), e);
+            throw new IllegalArgumentException(
+                    sm.getString("applicationContext.addListener.iae.init", listenerClass.getName()), e);
         }
         addListener(listener);
     }
@@ -1088,9 +1065,8 @@ public class ApplicationContext implements ServletContext {
                 Object obj = context.getInstanceManager().newInstance(className);
 
                 if (!(obj instanceof EventListener)) {
-                    throw new IllegalArgumentException(sm.getString(
-                            "applicationContext.addListener.iae.wrongType",
-                            className));
+                    throw new IllegalArgumentException(
+                            sm.getString("applicationContext.addListener.iae.wrongType", className));
                 }
 
                 EventListener listener = (EventListener) obj;
@@ -1098,13 +1074,9 @@ public class ApplicationContext implements ServletContext {
             }
         } catch (InvocationTargetException e) {
             ExceptionUtils.handleThrowable(e.getCause());
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationContext.addListener.iae.cnfe", className),
-                    e);
-        } catch (ReflectiveOperationException| NamingException e) {
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationContext.addListener.iae.cnfe", className),
-                    e);
+            throw new IllegalArgumentException(sm.getString("applicationContext.addListener.iae.cnfe", className), e);
+        } catch (ReflectiveOperationException | NamingException e) {
+            throw new IllegalArgumentException(sm.getString("applicationContext.addListener.iae.cnfe", className), e);
         }
 
     }
@@ -1115,10 +1087,8 @@ public class ApplicationContext implements ServletContext {
         checkState("applicationContext.addListener.ise");
 
         boolean match = false;
-        if (t instanceof ServletContextAttributeListener ||
-                t instanceof ServletRequestListener ||
-                t instanceof ServletRequestAttributeListener ||
-                t instanceof HttpSessionIdListener ||
+        if (t instanceof ServletContextAttributeListener || t instanceof ServletRequestListener ||
+                t instanceof ServletRequestAttributeListener || t instanceof HttpSessionIdListener ||
                 t instanceof HttpSessionAttributeListener) {
             context.addApplicationEventListener(t);
             match = true;
@@ -1137,35 +1107,28 @@ public class ApplicationContext implements ServletContext {
         }
 
         if (t instanceof ServletContextListener) {
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationContext.addListener.iae.sclNotAllowed",
-                    t.getClass().getName()));
+            throw new IllegalArgumentException(
+                    sm.getString("applicationContext.addListener.iae.sclNotAllowed", t.getClass().getName()));
         } else {
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationContext.addListener.iae.wrongType",
-                    t.getClass().getName()));
+            throw new IllegalArgumentException(
+                    sm.getString("applicationContext.addListener.iae.wrongType", t.getClass().getName()));
         }
     }
 
 
     @Override
-    public <T extends EventListener> T createListener(Class<T> c)
-            throws ServletException {
+    public <T extends EventListener> T createListener(Class<T> c) throws ServletException {
         try {
             @SuppressWarnings("unchecked")
             T listener = (T) context.getInstanceManager().newInstance(c);
-            if (listener instanceof ServletContextListener ||
-                    listener instanceof ServletContextAttributeListener ||
-                    listener instanceof ServletRequestListener ||
-                    listener instanceof ServletRequestAttributeListener ||
-                    listener instanceof HttpSessionListener ||
-                    listener instanceof HttpSessionIdListener ||
+            if (listener instanceof ServletContextListener || listener instanceof ServletContextAttributeListener ||
+                    listener instanceof ServletRequestListener || listener instanceof ServletRequestAttributeListener ||
+                    listener instanceof HttpSessionListener || listener instanceof HttpSessionIdListener ||
                     listener instanceof HttpSessionAttributeListener) {
                 return listener;
             }
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationContext.addListener.iae.wrongType",
-                    listener.getClass().getName()));
+            throw new IllegalArgumentException(
+                    sm.getString("applicationContext.addListener.iae.wrongType", listener.getClass().getName()));
         } catch (InvocationTargetException e) {
             ExceptionUtils.handleThrowable(e.getCause());
             throw new ServletException(e);
@@ -1182,16 +1145,12 @@ public class ApplicationContext implements ServletContext {
         checkState("applicationContext.addRole.ise");
 
         if (roleNames == null) {
-            throw new IllegalArgumentException(
-                    sm.getString("applicationContext.roles.iae",
-                            getContextPath()));
+            throw new IllegalArgumentException(sm.getString("applicationContext.roles.iae", getContextPath()));
         }
 
         for (String role : roleNames) {
             if (role == null || role.isEmpty()) {
-                throw new IllegalArgumentException(
-                        sm.getString("applicationContext.role.iae",
-                                getContextPath()));
+                throw new IllegalArgumentException(sm.getString("applicationContext.role.iae", getContextPath()));
             }
             context.addSecurityRole(role);
         }
@@ -1211,8 +1170,7 @@ public class ApplicationContext implements ServletContext {
                 parent = parent.getParent();
             }
             if (parent == null) {
-                System.getSecurityManager().checkPermission(
-                        new RuntimePermission("getClassLoader"));
+                System.getSecurityManager().checkPermission(new RuntimePermission("getClassLoader"));
             }
         }
 
@@ -1238,8 +1196,7 @@ public class ApplicationContext implements ServletContext {
 
         FilterDef[] filterDefs = context.findFilterDefs();
         for (FilterDef filterDef : filterDefs) {
-            result.put(filterDef.getFilterName(),
-                    new ApplicationFilterRegistration(filterDef, context));
+            result.put(filterDef.getFilterName(), new ApplicationFilterRegistration(filterDef, context));
         }
 
         return result;
@@ -1258,9 +1215,7 @@ public class ApplicationContext implements ServletContext {
 
         Container[] wrappers = context.findChildren();
         for (Container wrapper : wrappers) {
-            result.put(wrapper.getName(),
-                    new ApplicationServletRegistration(
-                            (Wrapper) wrapper, context));
+            result.put(wrapper.getName(), new ApplicationServletRegistration((Wrapper) wrapper, context));
         }
 
         return result;
@@ -1311,7 +1266,7 @@ public class ApplicationContext implements ServletContext {
 
     private void checkState(String messageKey) {
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(messageKey,getContextPath()));
+            throw new IllegalStateException(sm.getString(messageKey, getContextPath()));
         }
     }
 
@@ -1363,8 +1318,7 @@ public class ApplicationContext implements ServletContext {
     }
 
     /**
-     * Internal class used as thread-local storage when doing path
-     * mapping during dispatch.
+     * Internal class used as thread-local storage when doing path mapping during dispatch.
      */
     private static final class DispatchData {
 
diff --git a/java/org/apache/catalina/core/ApplicationContextFacade.java b/java/org/apache/catalina/core/ApplicationContextFacade.java
index 63e79b445b..0b7df11fdb 100644
--- a/java/org/apache/catalina/core/ApplicationContextFacade.java
+++ b/java/org/apache/catalina/core/ApplicationContextFacade.java
@@ -50,8 +50,7 @@ import org.apache.tomcat.util.ExceptionUtils;
 
 
 /**
- * Facade object which masks the internal <code>ApplicationContext</code>
- * object from the web application.
+ * Facade object which masks the internal <code>ApplicationContext</code> object from the web application.
  *
  * @author Remy Maucherat
  */
@@ -61,21 +60,20 @@ public class ApplicationContextFacade implements ServletContext {
     /**
      * Cache Class object used for reflection.
      */
-    private final Map<String,Class<?>[]> classCache;
+    private final Map<String, Class<?>[]> classCache;
 
 
     /**
      * Cache method object.
      */
-    private final Map<String,Method> objectCache;
+    private final Map<String, Method> objectCache;
 
 
     // ----------------------------------------------------------- Constructors
 
 
     /**
-     * Construct a new instance of this class, associated with the specified
-     * Context instance.
+     * Construct a new instance of this class, associated with the specified Context instance.
      *
      * @param context The associated Context instance
      */
@@ -89,8 +87,8 @@ public class ApplicationContextFacade implements ServletContext {
     }
 
 
-    private void initClassCache(){
-        Class<?>[] clazz = new Class[]{String.class};
+    private void initClassCache() {
+        Class<?>[] clazz = new Class[] { String.class };
         classCache.put("getContext", clazz);
         classCache.put("getMimeType", clazz);
         classCache.put("getResourcePaths", clazz);
@@ -99,27 +97,27 @@ public class ApplicationContextFacade implements ServletContext {
         classCache.put("getRequestDispatcher", clazz);
         classCache.put("getNamedDispatcher", clazz);
         classCache.put("getServlet", clazz);
-        classCache.put("setInitParameter", new Class[]{String.class, String.class});
-        classCache.put("createServlet", new Class[]{Class.class});
-        classCache.put("addServlet", new Class[]{String.class, String.class});
-        classCache.put("createFilter", new Class[]{Class.class});
-        classCache.put("addFilter", new Class[]{String.class, String.class});
-        classCache.put("createListener", new Class[]{Class.class});
+        classCache.put("setInitParameter", new Class[] { String.class, String.class });
+        classCache.put("createServlet", new Class[] { Class.class });
+        classCache.put("addServlet", new Class[] { String.class, String.class });
+        classCache.put("createFilter", new Class[] { Class.class });
+        classCache.put("addFilter", new Class[] { String.class, String.class });
+        classCache.put("createListener", new Class[] { Class.class });
         classCache.put("addListener", clazz);
         classCache.put("getFilterRegistration", clazz);
         classCache.put("getServletRegistration", clazz);
         classCache.put("getInitParameter", clazz);
-        classCache.put("setAttribute", new Class[]{String.class, Object.class});
+        classCache.put("setAttribute", new Class[] { String.class, Object.class });
         classCache.put("removeAttribute", clazz);
         classCache.put("getRealPath", clazz);
         classCache.put("getAttribute", clazz);
         classCache.put("log", clazz);
-        classCache.put("setSessionTrackingModes", new Class[]{Set.class} );
-        classCache.put("addJspFile", new Class[]{String.class, String.class});
-        classCache.put("declareRoles", new Class[]{String[].class});
-        classCache.put("setSessionTimeout", new Class[]{int.class});
-        classCache.put("setRequestCharacterEncoding", new Class[]{String.class});
-        classCache.put("setResponseCharacterEncoding", new Class[]{String.class});
+        classCache.put("setSessionTrackingModes", new Class[] { Set.class });
+        classCache.put("addJspFile", new Class[] { String.class, String.class });
+        classCache.put("declareRoles", new Class[] { String[].class });
+        classCache.put("setSessionTimeout", new Class[] { int.class });
+        classCache.put("setRequestCharacterEncoding", new Class[] { String.class });
+        classCache.put("setResponseCharacterEncoding", new Class[] { String.class });
     }
 
 
@@ -139,14 +137,12 @@ public class ApplicationContextFacade implements ServletContext {
     public ServletContext getContext(String uripath) {
         ServletContext theContext = null;
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            theContext = (ServletContext)
-                doPrivileged("getContext", new Object[]{uripath});
+            theContext = (ServletContext) doPrivileged("getContext", new Object[] { uripath });
         } else {
             theContext = context.getContext(uripath);
         }
-        if ((theContext != null) &&
-            (theContext instanceof ApplicationContext)){
-            theContext = ((ApplicationContext)theContext).getFacade();
+        if ((theContext != null) && (theContext instanceof ApplicationContext)) {
+            theContext = ((ApplicationContext) theContext).getFacade();
         }
         return theContext;
     }
@@ -167,7 +163,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public String getMimeType(String file) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (String)doPrivileged("getMimeType", new Object[]{file});
+            return (String) doPrivileged("getMimeType", new Object[] { file });
         } else {
             return context.getMimeType(file);
         }
@@ -176,9 +172,8 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
     public Set<String> getResourcePaths(String path) {
-        if (SecurityUtil.isPackageProtectionEnabled()){
-            return (Set<String>)doPrivileged("getResourcePaths",
-                    new Object[]{path});
+        if (SecurityUtil.isPackageProtectionEnabled()) {
+            return (Set<String>) doPrivileged("getResourcePaths", new Object[] { path });
         } else {
             return context.getResourcePaths(path);
         }
@@ -186,16 +181,14 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     @Override
-    public URL getResource(String path)
-        throws MalformedURLException {
+    public URL getResource(String path) throws MalformedURLException {
         if (Globals.IS_SECURITY_ENABLED) {
             try {
-                return (URL) invokeMethod(context, "getResource",
-                                          new Object[]{path});
-            } catch(Throwable t) {
+                return (URL) invokeMethod(context, "getResource", new Object[] { path });
+            } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
-                if (t instanceof MalformedURLException){
-                    throw (MalformedURLException)t;
+                if (t instanceof MalformedURLException) {
+                    throw (MalformedURLException) t;
                 }
                 return null;
             }
@@ -208,8 +201,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public InputStream getResourceAsStream(String path) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (InputStream) doPrivileged("getResourceAsStream",
-                                              new Object[]{path});
+            return (InputStream) doPrivileged("getResourceAsStream", new Object[] { path });
         } else {
             return context.getResourceAsStream(path);
         }
@@ -219,8 +211,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public RequestDispatcher getRequestDispatcher(final String path) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (RequestDispatcher) doPrivileged("getRequestDispatcher",
-                                                    new Object[]{path});
+            return (RequestDispatcher) doPrivileged("getRequestDispatcher", new Object[] { path });
         } else {
             return context.getRequestDispatcher(path);
         }
@@ -230,8 +221,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public RequestDispatcher getNamedDispatcher(String name) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (RequestDispatcher) doPrivileged("getNamedDispatcher",
-                                                    new Object[]{name});
+            return (RequestDispatcher) doPrivileged("getNamedDispatcher", new Object[] { name });
         } else {
             return context.getNamedDispatcher(name);
         }
@@ -243,12 +233,10 @@ public class ApplicationContextFacade implements ServletContext {
      */
     @Override
     @Deprecated
-    public Servlet getServlet(String name)
-        throws ServletException {
+    public Servlet getServlet(String name) throws ServletException {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             try {
-                return (Servlet) invokeMethod(context, "getServlet",
-                                              new Object[]{name});
+                return (Servlet) invokeMethod(context, "getServlet", new Object[] { name });
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
                 if (t instanceof ServletException) {
@@ -289,13 +277,13 @@ public class ApplicationContextFacade implements ServletContext {
         } else {
             return context.getServletNames();
         }
-   }
+    }
 
 
     @Override
     public void log(String msg) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("log", new Object[]{msg} );
+            doPrivileged("log", new Object[] { msg });
         } else {
             context.log(msg);
         }
@@ -303,15 +291,13 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     /**
-     * @deprecated As of Java Servlet API 2.1, use
-     *  <code>log(String, Throwable)</code> instead
+     * @deprecated As of Java Servlet API 2.1, use <code>log(String, Throwable)</code> instead
      */
     @Override
     @Deprecated
     public void log(Exception exception, String msg) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("log", new Class[]{Exception.class, String.class},
-                         new Object[]{exception,msg});
+            doPrivileged("log", new Class[] { Exception.class, String.class }, new Object[] { exception, msg });
         } else {
             context.log(exception, msg);
         }
@@ -321,8 +307,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public void log(String message, Throwable throwable) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("log", new Class[]{String.class, Throwable.class},
-                         new Object[]{message, throwable});
+            doPrivileged("log", new Class[] { String.class, Throwable.class }, new Object[] { message, throwable });
         } else {
             context.log(message, throwable);
         }
@@ -332,7 +317,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public String getRealPath(String path) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (String) doPrivileged("getRealPath", new Object[]{path});
+            return (String) doPrivileged("getRealPath", new Object[] { path });
         } else {
             return context.getRealPath(path);
         }
@@ -352,8 +337,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public String getInitParameter(String name) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (String) doPrivileged("getInitParameter",
-                                         new Object[]{name});
+            return (String) doPrivileged("getInitParameter", new Object[] { name });
         } else {
             return context.getInitParameter(name);
         }
@@ -364,8 +348,7 @@ public class ApplicationContextFacade implements ServletContext {
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
     public Enumeration<String> getInitParameterNames() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (Enumeration<String>) doPrivileged(
-                    "getInitParameterNames", null);
+            return (Enumeration<String>) doPrivileged("getInitParameterNames", null);
         } else {
             return context.getInitParameterNames();
         }
@@ -375,19 +358,18 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public Object getAttribute(String name) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return doPrivileged("getAttribute", new Object[]{name});
+            return doPrivileged("getAttribute", new Object[] { name });
         } else {
             return context.getAttribute(name);
         }
-     }
+    }
 
 
     @Override
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
     public Enumeration<String> getAttributeNames() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (Enumeration<String>) doPrivileged(
-                    "getAttributeNames", null);
+            return (Enumeration<String>) doPrivileged("getAttributeNames", null);
         } else {
             return context.getAttributeNames();
         }
@@ -397,7 +379,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public void setAttribute(String name, Object object) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("setAttribute", new Object[]{name,object});
+            doPrivileged("setAttribute", new Object[] { name, object });
         } else {
             context.setAttribute(name, object);
         }
@@ -407,7 +389,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public void removeAttribute(String name) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("removeAttribute", new Object[]{name});
+            doPrivileged("removeAttribute", new Object[] { name });
         } else {
             context.removeAttribute(name);
         }
@@ -435,11 +417,9 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     @Override
-    public FilterRegistration.Dynamic addFilter(String filterName,
-            String className) {
+    public FilterRegistration.Dynamic addFilter(String filterName, String className) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (FilterRegistration.Dynamic) doPrivileged(
-                    "addFilter", new Object[]{filterName, className});
+            return (FilterRegistration.Dynamic) doPrivileged("addFilter", new Object[] { filterName, className });
         } else {
             return context.addFilter(filterName, className);
         }
@@ -447,12 +427,10 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     @Override
-    public FilterRegistration.Dynamic addFilter(String filterName,
-            Filter filter) {
+    public FilterRegistration.Dynamic addFilter(String filterName, Filter filter) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (FilterRegistration.Dynamic) doPrivileged("addFilter",
-                    new Class[]{String.class, Filter.class},
-                    new Object[]{filterName, filter});
+            return (FilterRegistration.Dynamic) doPrivileged("addFilter", new Class[] { String.class, Filter.class },
+                    new Object[] { filterName, filter });
         } else {
             return context.addFilter(filterName, filter);
         }
@@ -460,12 +438,10 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     @Override
-    public FilterRegistration.Dynamic addFilter(String filterName,
-            Class<? extends Filter> filterClass) {
+    public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (FilterRegistration.Dynamic) doPrivileged("addFilter",
-                    new Class[]{String.class, Class.class},
-                    new Object[]{filterName, filterClass});
+            return (FilterRegistration.Dynamic) doPrivileged("addFilter", new Class[] { String.class, Class.class },
+                    new Object[] { filterName, filterClass });
         } else {
             return context.addFilter(filterName, filterClass);
         }
@@ -473,12 +449,10 @@ public class ApplicationContextFacade implements ServletContext {
 
     @Override
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
-    public <T extends Filter> T createFilter(Class<T> c)
-    throws ServletException {
+    public <T extends Filter> T createFilter(Class<T> c) throws ServletException {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             try {
-                return (T) invokeMethod(context, "createFilter",
-                                              new Object[]{c});
+                return (T) invokeMethod(context, "createFilter", new Object[] { c });
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
                 if (t instanceof ServletException) {
@@ -495,8 +469,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public FilterRegistration getFilterRegistration(String filterName) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (FilterRegistration) doPrivileged(
-                    "getFilterRegistration", new Object[]{filterName});
+            return (FilterRegistration) doPrivileged("getFilterRegistration", new Object[] { filterName });
         } else {
             return context.getFilterRegistration(filterName);
         }
@@ -504,11 +477,9 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     @Override
-    public ServletRegistration.Dynamic addServlet(String servletName,
-            String className) {
+    public ServletRegistration.Dynamic addServlet(String servletName, String className) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (ServletRegistration.Dynamic) doPrivileged(
-                    "addServlet", new Object[]{servletName, className});
+            return (ServletRegistration.Dynamic) doPrivileged("addServlet", new Object[] { servletName, className });
         } else {
             return context.addServlet(servletName, className);
         }
@@ -516,12 +487,10 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     @Override
-    public ServletRegistration.Dynamic addServlet(String servletName,
-            Servlet servlet) {
+    public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (ServletRegistration.Dynamic) doPrivileged("addServlet",
-                    new Class[]{String.class, Servlet.class},
-                    new Object[]{servletName, servlet});
+            return (ServletRegistration.Dynamic) doPrivileged("addServlet", new Class[] { String.class, Servlet.class },
+                    new Object[] { servletName, servlet });
         } else {
             return context.addServlet(servletName, servlet);
         }
@@ -529,12 +498,10 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     @Override
-    public ServletRegistration.Dynamic addServlet(String servletName,
-            Class<? extends Servlet> servletClass) {
+    public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (ServletRegistration.Dynamic) doPrivileged("addServlet",
-                    new Class[]{String.class, Class.class},
-                    new Object[]{servletName, servletClass});
+            return (ServletRegistration.Dynamic) doPrivileged("addServlet", new Class[] { String.class, Class.class },
+                    new Object[] { servletName, servletClass });
         } else {
             return context.addServlet(servletName, servletClass);
         }
@@ -543,8 +510,7 @@ public class ApplicationContextFacade implements ServletContext {
 
     public Dynamic addJspFile(String jspName, String jspFile) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (ServletRegistration.Dynamic) doPrivileged("addJspFile",
-                    new Object[]{jspName, jspFile});
+            return (ServletRegistration.Dynamic) doPrivileged("addJspFile", new Object[] { jspName, jspFile });
         } else {
             return context.addJspFile(jspName, jspFile);
         }
@@ -553,12 +519,10 @@ public class ApplicationContextFacade implements ServletContext {
 
     @Override
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
-    public <T extends Servlet> T createServlet(Class<T> c)
-    throws ServletException {
+    public <T extends Servlet> T createServlet(Class<T> c) throws ServletException {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             try {
-                return (T) invokeMethod(context, "createServlet",
-                                              new Object[]{c});
+                return (T) invokeMethod(context, "createServlet", new Object[] { c });
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
                 if (t instanceof ServletException) {
@@ -575,8 +539,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public ServletRegistration getServletRegistration(String servletName) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (ServletRegistration) doPrivileged(
-                    "getServletRegistration", new Object[]{servletName});
+            return (ServletRegistration) doPrivileged("getServletRegistration", new Object[] { servletName });
         } else {
             return context.getServletRegistration(servletName);
         }
@@ -587,8 +550,7 @@ public class ApplicationContextFacade implements ServletContext {
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
     public Set<SessionTrackingMode> getDefaultSessionTrackingModes() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (Set<SessionTrackingMode>)
-                doPrivileged("getDefaultSessionTrackingModes", null);
+            return (Set<SessionTrackingMode>) doPrivileged("getDefaultSessionTrackingModes", null);
         } else {
             return context.getDefaultSessionTrackingModes();
         }
@@ -598,8 +560,7 @@ public class ApplicationContextFacade implements ServletContext {
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
     public Set<SessionTrackingMode> getEffectiveSessionTrackingModes() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (Set<SessionTrackingMode>)
-                doPrivileged("getEffectiveSessionTrackingModes", null);
+            return (Set<SessionTrackingMode>) doPrivileged("getEffectiveSessionTrackingModes", null);
         } else {
             return context.getEffectiveSessionTrackingModes();
         }
@@ -609,8 +570,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public SessionCookieConfig getSessionCookieConfig() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (SessionCookieConfig)
-                doPrivileged("getSessionCookieConfig", null);
+            return (SessionCookieConfig) doPrivileged("getSessionCookieConfig", null);
         } else {
             return context.getSessionCookieConfig();
         }
@@ -618,11 +578,9 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     @Override
-    public void setSessionTrackingModes(
-            Set<SessionTrackingMode> sessionTrackingModes) {
+    public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("setSessionTrackingModes",
-                    new Object[]{sessionTrackingModes});
+            doPrivileged("setSessionTrackingModes", new Object[] { sessionTrackingModes });
         } else {
             context.setSessionTrackingModes(sessionTrackingModes);
         }
@@ -632,8 +590,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public boolean setInitParameter(String name, String value) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return ((Boolean) doPrivileged("setInitParameter",
-                    new Object[]{name, value})).booleanValue();
+            return ((Boolean) doPrivileged("setInitParameter", new Object[] { name, value })).booleanValue();
         } else {
             return context.setInitParameter(name, value);
         }
@@ -643,9 +600,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public void addListener(Class<? extends EventListener> listenerClass) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("addListener",
-                    new Class[]{Class.class},
-                    new Object[]{listenerClass});
+            doPrivileged("addListener", new Class[] { Class.class }, new Object[] { listenerClass });
         } else {
             context.addListener(listenerClass);
         }
@@ -655,8 +610,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public void addListener(String className) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("addListener",
-                    new Object[]{className});
+            doPrivileged("addListener", new Object[] { className });
         } else {
             context.addListener(className);
         }
@@ -666,9 +620,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public <T extends EventListener> void addListener(T t) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("addListener",
-                    new Class[]{EventListener.class},
-                    new Object[]{t});
+            doPrivileged("addListener", new Class[] { EventListener.class }, new Object[] { t });
         } else {
             context.addListener(t);
         }
@@ -677,12 +629,10 @@ public class ApplicationContextFacade implements ServletContext {
 
     @Override
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
-    public <T extends EventListener> T createListener(Class<T> c)
-            throws ServletException {
+    public <T extends EventListener> T createListener(Class<T> c) throws ServletException {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             try {
-                return (T) invokeMethod(context, "createListener",
-                                              new Object[]{c});
+                return (T) invokeMethod(context, "createListener", new Object[] { c });
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
                 if (t instanceof ServletException) {
@@ -699,7 +649,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public void declareRoles(String... roleNames) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            doPrivileged("declareRoles", new Object[]{roleNames});
+            doPrivileged("declareRoles", new Object[] { roleNames });
         } else {
             context.declareRoles(roleNames);
         }
@@ -719,9 +669,8 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public int getEffectiveMajorVersion() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return ((Integer) doPrivileged("getEffectiveMajorVersion",
-                    null)).intValue();
-        } else  {
+            return ((Integer) doPrivileged("getEffectiveMajorVersion", null)).intValue();
+        } else {
             return context.getEffectiveMajorVersion();
         }
     }
@@ -730,9 +679,8 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public int getEffectiveMinorVersion() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return ((Integer) doPrivileged("getEffectiveMinorVersion",
-                    null)).intValue();
-        } else  {
+            return ((Integer) doPrivileged("getEffectiveMinorVersion", null)).intValue();
+        } else {
             return context.getEffectiveMinorVersion();
         }
     }
@@ -742,8 +690,7 @@ public class ApplicationContextFacade implements ServletContext {
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
     public Map<String, ? extends FilterRegistration> getFilterRegistrations() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (Map<String, ? extends FilterRegistration>) doPrivileged(
-                    "getFilterRegistrations", null);
+            return (Map<String, ? extends FilterRegistration>) doPrivileged("getFilterRegistrations", null);
         } else {
             return context.getFilterRegistrations();
         }
@@ -753,8 +700,7 @@ public class ApplicationContextFacade implements ServletContext {
     @Override
     public JspConfigDescriptor getJspConfigDescriptor() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (JspConfigDescriptor) doPrivileged("getJspConfigDescriptor",
-                    null);
+            return (JspConfigDescriptor) doPrivileged("getJspConfigDescriptor", null);
         } else {
             return context.getJspConfigDescriptor();
         }
@@ -765,8 +711,7 @@ public class ApplicationContextFacade implements ServletContext {
     @SuppressWarnings("unchecked") // doPrivileged() returns the correct type
     public Map<String, ? extends ServletRegistration> getServletRegistrations() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
-            return (Map<String, ? extends ServletRegistration>) doPrivileged(
-                    "getServletRegistrations", null);
+            return (Map<String, ? extends ServletRegistration>) doPrivileged("getServletRegistrations", null);
         } else {
             return context.getServletRegistrations();
         }
@@ -777,7 +722,7 @@ public class ApplicationContextFacade implements ServletContext {
     public String getVirtualServerName() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             return (String) doPrivileged("getVirtualServerName", null);
-        } else  {
+        } else {
             return context.getVirtualServerName();
         }
     }
@@ -786,7 +731,7 @@ public class ApplicationContextFacade implements ServletContext {
     public int getSessionTimeout() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             return ((Integer) doPrivileged("getSessionTimeout", null)).intValue();
-        } else  {
+        } else {
             return context.getSessionTimeout();
         }
     }
@@ -795,7 +740,7 @@ public class ApplicationContextFacade implements ServletContext {
     public void setSessionTimeout(int sessionTimeout) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             doPrivileged("setSessionTimeout", new Object[] { Integer.valueOf(sessionTimeout) });
-        } else  {
+        } else {
             context.setSessionTimeout(sessionTimeout);
         }
     }
@@ -804,7 +749,7 @@ public class ApplicationContextFacade implements ServletContext {
     public String getRequestCharacterEncoding() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             return (String) doPrivileged("getRequestCharacterEncoding", null);
-        } else  {
+        } else {
             return context.getRequestCharacterEncoding();
         }
     }
@@ -813,7 +758,7 @@ public class ApplicationContextFacade implements ServletContext {
     public void setRequestCharacterEncoding(String encoding) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             doPrivileged("setRequestCharacterEncoding", new Object[] { encoding });
-        } else  {
+        } else {
             context.setRequestCharacterEncoding(encoding);
         }
     }
@@ -822,7 +767,7 @@ public class ApplicationContextFacade implements ServletContext {
     public String getResponseCharacterEncoding() {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             return (String) doPrivileged("getResponseCharacterEncoding", null);
-        } else  {
+        } else {
             return context.getResponseCharacterEncoding();
         }
     }
@@ -831,22 +776,22 @@ public class ApplicationContextFacade implements ServletContext {
     public void setResponseCharacterEncoding(String encoding) {
         if (SecurityUtil.isPackageProtectionEnabled()) {
             doPrivileged("setResponseCharacterEncoding", new Object[] { encoding });
-        } else  {
+        } else {
             context.setResponseCharacterEncoding(encoding);
         }
     }
 
 
     /**
-     * Use reflection to invoke the requested method. Cache the method object
-     * to speed up the process
+     * Use reflection to invoke the requested method. Cache the method object to speed up the process
+     *
      * @param methodName The method to call.
-     * @param params The arguments passed to the called method.
+     * @param params     The arguments passed to the called method.
      */
     private Object doPrivileged(final String methodName, final Object[] params) {
-        try{
+        try {
             return invokeMethod(context, methodName, params);
-        }catch(Throwable t){
+        } catch (Throwable t) {
             ExceptionUtils.handleThrowable(t);
             throw new RuntimeException(t.getMessage(), t);
         }
@@ -854,28 +799,24 @@ public class ApplicationContextFacade implements ServletContext {
 
 
     /**
-     * Use reflection to invoke the requested method. Cache the method object
-     * to speed up the process
-     * @param appContext The ApplicationContext object on which the method
-     *                   will be invoked
+     * Use reflection to invoke the requested method. Cache the method object to speed up the process
+     *
+     * @param appContext The ApplicationContext object on which the method will be invoked
      * @param methodName The method to call.
-     * @param params The arguments passed to the called method.
+     * @param params     The arguments passed to the called method.
      */
-    private Object invokeMethod(ApplicationContext appContext,
-                                final String methodName,
-                                Object[] params)
-        throws Throwable{
+    private Object invokeMethod(ApplicationContext appContext, final String methodName, Object[] params)
+            throws Throwable {
 
-        try{
+        try {
             Method method = objectCache.get(methodName);
-            if (method == null){
-                method = appContext.getClass()
-                    .getMethod(methodName, classCache.get(methodName));
+            if (method == null) {
+                method = appContext.getClass().getMethod(methodName, classCache.get(methodName));
                 objectCache.put(methodName, method);
             }
 
-            return executeMethod(method,appContext,params);
-        } catch (Exception ex){
+            return executeMethod(method, appContext, params);
+        } catch (Exception ex) {
             handleException(ex);
             return null;
         } finally {
@@ -884,23 +825,21 @@ public class ApplicationContextFacade implements ServletContext {
     }
 
     /**
-     * Use reflection to invoke the requested method. Cache the method object
-     * to speed up the process
+     * Use reflection to invoke the requested method. Cache the method object to speed up the process
+     *
      * @param methodName The method to invoke.
-     * @param clazz The class where the method is.
-     * @param params The arguments passed to the called method.
+     * @param clazz      The class where the method is.
+     * @param params     The arguments passed to the called method.
      */
-    private Object doPrivileged(final String methodName,
-                                final Class<?>[] clazz,
-                                Object[] params) {
+    private Object doPrivileged(final String methodName, final Class<?>[] clazz, Object[] params) {
 
-        try{
+        try {
             Method method = context.getClass().getMethod(methodName, clazz);
-            return executeMethod(method,context,params);
-        } catch (Exception ex){
+            return executeMethod(method, context, params);
+        } catch (Exception ex) {
             try {
                 handleException(ex);
-            } catch (Throwable t){
+            } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
                 throw new RuntimeException(t.getMessage());
             }
@@ -913,21 +852,16 @@ public class ApplicationContextFacade implements ServletContext {
 
     /**
      * Executes the method of the specified <code>ApplicationContext</code>
-     * @param method The method object to be invoked.
-     * @param context The ApplicationContext object on which the method
-     *                   will be invoked
-     * @param params The arguments passed to the called method.
+     *
+     * @param method  The method object to be invoked.
+     * @param context The ApplicationContext object on which the method will be invoked
+     * @param params  The arguments passed to the called method.
      */
-    private Object executeMethod(final Method method,
-                                 final ApplicationContext context,
-                                 final Object[] params)
-            throws PrivilegedActionException,
-                   IllegalAccessException,
-                   InvocationTargetException {
+    private Object executeMethod(final Method method, final ApplicationContext context, final Object[] params)
+            throws PrivilegedActionException, IllegalAccessException, InvocationTargetException {
 
-        if (SecurityUtil.isPackageProtectionEnabled()){
-           return AccessController.doPrivileged(
-                   new PrivilegedExecuteMethod(method, context,  params));
+        if (SecurityUtil.isPackageProtectionEnabled()) {
+            return AccessController.doPrivileged(new PrivilegedExecuteMethod(method, context, params));
         } else {
             return method.invoke(context, params);
         }
@@ -939,8 +873,7 @@ public class ApplicationContextFacade implements ServletContext {
      *
      * @param ex The current exception
      */
-    private void handleException(Exception ex)
-        throws Throwable {
+    private void handleException(Exception ex) throws Throwable {
 
         Throwable realException;
 
diff --git a/java/org/apache/catalina/core/ApplicationDispatcher.java b/java/org/apache/catalina/core/ApplicationDispatcher.java
index 443c65ce3f..1e3dfc2abb 100644
--- a/java/org/apache/catalina/core/ApplicationDispatcher.java
+++ b/java/org/apache/catalina/core/ApplicationDispatcher.java
@@ -48,14 +48,11 @@ import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
- * Standard implementation of <code>RequestDispatcher</code> that allows a
- * request to be forwarded to a different resource to create the ultimate
- * response, or to include the output of another resource in the response
- * from this resource.  This implementation allows application level servlets
- * to wrap the request and/or response objects that are passed on to the
- * called resource, as long as the wrapping classes extend
- * <code>javax.servlet.ServletRequestWrapper</code> and
- * <code>javax.servlet.ServletResponseWrapper</code>.
+ * Standard implementation of <code>RequestDispatcher</code> that allows a request to be forwarded to a different
+ * resource to create the ultimate response, or to include the output of another resource in the response from this
+ * resource. This implementation allows application level servlets to wrap the request and/or response objects that are
+ * passed on to the called resource, as long as the wrapping classes extend
+ * <code>javax.servlet.ServletRequestWrapper</code> and <code>javax.servlet.ServletResponseWrapper</code>.
  *
  * @author Craig R. McClanahan
  */
@@ -74,8 +71,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
     static {
         STRICT_SERVLET_COMPLIANCE = Globals.STRICT_SERVLET_COMPLIANCE;
 
-        String wrapSameObject = System.getProperty(
-                "org.apache.catalina.core.ApplicationDispatcher.WRAP_SAME_OBJECT");
+        String wrapSameObject = System.getProperty("org.apache.catalina.core.ApplicationDispatcher.WRAP_SAME_OBJECT");
         if (wrapSameObject == null) {
             WRAP_SAME_OBJECT = STRICT_SERVLET_COMPLIANCE;
         } else {
@@ -84,8 +80,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
     }
 
 
-    protected class PrivilegedForward
-            implements PrivilegedExceptionAction<Void> {
+    protected class PrivilegedForward implements PrivilegedExceptionAction<Void> {
         private final ServletRequest request;
         private final ServletResponse response;
 
@@ -96,13 +91,12 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
         @Override
         public Void run() throws java.lang.Exception {
-            doForward(request,response);
+            doForward(request, response);
             return null;
         }
     }
 
-    protected class PrivilegedInclude implements
-            PrivilegedExceptionAction<Void> {
+    protected class PrivilegedInclude implements PrivilegedExceptionAction<Void> {
         private final ServletRequest request;
         private final ServletResponse response;
 
@@ -118,8 +112,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         }
     }
 
-    protected class PrivilegedDispatch implements
-            PrivilegedExceptionAction<Void> {
+    protected class PrivilegedDispatch implements PrivilegedExceptionAction<Void> {
         private final ServletRequest request;
         private final ServletResponse response;
 
@@ -137,13 +130,11 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * Used to pass state when the request dispatcher is used. Using instance
-     * variables causes threading issues and state is too complex to pass and
-     * return single ServletRequest or ServletResponse objects.
+     * Used to pass state when the request dispatcher is used. Using instance variables causes threading issues and
+     * state is too complex to pass and return single ServletRequest or ServletResponse objects.
      */
     private static class State {
-        State(ServletRequest request, ServletResponse response,
-                boolean including) {
+        State(ServletRequest request, ServletResponse response, boolean including) {
             this.outerRequest = request;
             this.outerResponse = response;
             this.including = including;
@@ -191,26 +182,20 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * Construct a new instance of this class, configured according to the
-     * specified parameters.  If both servletPath and pathInfo are
-     * <code>null</code>, it will be assumed that this RequestDispatcher
-     * was acquired by name, rather than by path.
+     * Construct a new instance of this class, configured according to the specified parameters. If both servletPath and
+     * pathInfo are <code>null</code>, it will be assumed that this RequestDispatcher was acquired by name, rather than
+     * by path.
      *
-     * @param wrapper The Wrapper associated with the resource that will
-     *  be forwarded to or included (required)
-     * @param requestURI The request URI to this resource (if any)
+     * @param wrapper     The Wrapper associated with the resource that will be forwarded to or included (required)
+     * @param requestURI  The request URI to this resource (if any)
      * @param servletPath The revised servlet path to this resource (if any)
-     * @param pathInfo The revised extra path information to this resource
-     *  (if any)
-     * @param queryString Query string parameters included with this request
-     *  (if any)
-     * @param mapping The mapping for this resource (if any)
-     * @param name Servlet name (if a named dispatcher was created)
-     *  else <code>null</code>
+     * @param pathInfo    The revised extra path information to this resource (if any)
+     * @param queryString Query string parameters included with this request (if any)
+     * @param mapping     The mapping for this resource (if any)
+     * @param name        Servlet name (if a named dispatcher was created) else <code>null</code>
      */
-    public ApplicationDispatcher
-        (Wrapper wrapper, String requestURI, String servletPath,
-         String pathInfo, String queryString, ApplicationMappingImpl mapping, String name) {
+    public ApplicationDispatcher(Wrapper wrapper, String requestURI, String servletPath, String pathInfo,
+            String queryString, ApplicationMappingImpl mapping, String name) {
 
         super();
 
@@ -277,8 +262,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * The Wrapper associated with the resource that will be forwarded to
-     * or included.
+     * The Wrapper associated with the resource that will be forwarded to or included.
      */
     private final Wrapper wrapper;
 
@@ -287,23 +271,20 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * Forward this request and response to another resource for processing.
-     * Any runtime exception, IOException, or ServletException thrown by the
-     * called servlet will be propagated to the caller.
+     * Forward this request and response to another resource for processing. Any runtime exception, IOException, or
+     * ServletException thrown by the called servlet will be propagated to the caller.
      *
-     * @param request The servlet request to be forwarded
+     * @param request  The servlet request to be forwarded
      * @param response The servlet response to be forwarded
      *
-     * @exception IOException if an input/output error occurs
+     * @exception IOException      if an input/output error occurs
      * @exception ServletException if a servlet exception occurs
      */
     @Override
-    public void forward(ServletRequest request, ServletResponse response)
-        throws ServletException, IOException
-    {
+    public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
         if (Globals.IS_SECURITY_ENABLED) {
             try {
-                PrivilegedForward dp = new PrivilegedForward(request,response);
+                PrivilegedForward dp = new PrivilegedForward(request, response);
                 AccessController.doPrivileged(dp);
             } catch (PrivilegedActionException pe) {
                 Exception e = pe.getException();
@@ -313,18 +294,15 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
                 throw (IOException) e;
             }
         } else {
-            doForward(request,response);
+            doForward(request, response);
         }
     }
 
-    private void doForward(ServletRequest request, ServletResponse response)
-        throws ServletException, IOException
-    {
+    private void doForward(ServletRequest request, ServletResponse response) throws ServletException, IOException {
 
         // Reset any output that has been buffered, but keep headers/cookies
         if (response.isCommitted()) {
-            throw new IllegalStateException
-                (sm.getString("applicationDispatcher.forward.ise"));
+            throw new IllegalStateException(sm.getString("applicationDispatcher.forward.ise"));
         }
         try {
             response.resetBuffer();
@@ -344,8 +322,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         // Handle an HTTP named dispatcher forward
         if ((servletPath == null) && (pathInfo == null)) {
 
-            ApplicationHttpRequest wrequest =
-                (ApplicationHttpRequest) wrapRequest(state);
+            ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
             HttpServletRequest hrequest = state.hrequest;
             wrequest.setRequestURI(hrequest.getRequestURI());
             wrequest.setContextPath(hrequest.getContextPath());
@@ -353,7 +330,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
             wrequest.setPathInfo(hrequest.getPathInfo());
             wrequest.setQueryString(hrequest.getQueryString());
 
-            processRequest(request,response,state);
+            processRequest(request, response, state);
         }
 
         // Handle an HTTP path-based forward
@@ -362,16 +339,11 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
             ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
             HttpServletRequest hrequest = state.hrequest;
             if (hrequest.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI) == null) {
-                wrequest.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI,
-                                      hrequest.getRequestURI());
-                wrequest.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH,
-                                      hrequest.getContextPath());
-                wrequest.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH,
-                                      hrequest.getServletPath());
-                wrequest.setAttribute(RequestDispatcher.FORWARD_PATH_INFO,
-                                      hrequest.getPathInfo());
-                wrequest.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING,
-                                      hrequest.getQueryString());
+                wrequest.setAttribute(RequestDispatcher.FORWARD_REQUEST_URI, hrequest.getRequestURI());
+                wrequest.setAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH, hrequest.getContextPath());
+                wrequest.setAttribute(RequestDispatcher.FORWARD_SERVLET_PATH, hrequest.getServletPath());
+                wrequest.setAttribute(RequestDispatcher.FORWARD_PATH_INFO, hrequest.getPathInfo());
+                wrequest.setAttribute(RequestDispatcher.FORWARD_QUERY_STRING, hrequest.getQueryString());
                 wrequest.setAttribute(FORWARD_MAPPING, ApplicationMapping.getHttpServletMapping(hrequest));
             }
 
@@ -385,7 +357,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
             }
             wrequest.setMapping(mapping);
 
-            processRequest(request,response,state);
+            processRequest(request, response, state);
         }
 
         if (request.isAsyncStarted()) {
@@ -395,18 +367,18 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         }
 
         // This is not a real close in order to support error processing
-        if (wrapper.getLogger().isDebugEnabled() ) {
+        if (wrapper.getLogger().isDebugEnabled()) {
             wrapper.getLogger().debug(" Disabling the response for further output");
         }
 
-        if  (response instanceof ResponseFacade) {
+        if (response instanceof ResponseFacade) {
             ((ResponseFacade) response).finish();
         } else {
             // Servlet SRV.6.2.2. The Request/Response may have been wrapped
             // and may no longer be instance of RequestFacade
-            if (wrapper.getLogger().isDebugEnabled()){
-                wrapper.getLogger().debug( " The Response is vehiculed using a wrapper: "
-                           + response.getClass().getName() );
+            if (wrapper.getLogger().isDebugEnabled()) {
+                wrapper.getLogger()
+                        .debug(" The Response is vehiculed using a wrapper: " + response.getClass().getName());
             }
 
             // Close anyway
@@ -430,35 +402,29 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
     /**
      * Prepare the request based on the filter configuration.
-     * @param request The servlet request we are processing
+     *
+     * @param request  The servlet request we are processing
      * @param response The servlet response we are creating
-     * @param state The RD state
+     * @param state    The RD state
      *
-     * @exception IOException if an input/output error occurs
+     * @exception IOException      if an input/output error occurs
      * @exception ServletException if a servlet error occurs
      */
-    private void processRequest(ServletRequest request,
-                                ServletResponse response,
-                                State state)
-        throws IOException, ServletException {
+    private void processRequest(ServletRequest request, ServletResponse response, State state)
+            throws IOException, ServletException {
 
         DispatcherType disInt = (DispatcherType) request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
         if (disInt != null) {
             boolean doInvoke = true;
 
-            if (context.getFireRequestListenersOnForwards() &&
-                    !context.fireRequestInitEvent(request)) {
+            if (context.getFireRequestListenersOnForwards() && !context.fireRequestInitEvent(request)) {
                 doInvoke = false;
             }
 
             if (doInvoke) {
                 if (disInt != DispatcherType.ERROR) {
-                    state.outerRequest.setAttribute(
-                            Globals.DISPATCHER_REQUEST_PATH_ATTR,
-                            getCombinedPath());
-                    state.outerRequest.setAttribute(
-                            Globals.DISPATCHER_TYPE_ATTR,
-                            DispatcherType.FORWARD);
+                    state.outerRequest.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR, getCombinedPath());
+                    state.outerRequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.FORWARD);
                     invoke(state.outerRequest, response, state);
                 } else {
                     invoke(state.outerRequest, response, state);
@@ -473,9 +439,9 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * Combine the servletPath and the pathInfo. If pathInfo is
-     * <code>null</code> it is ignored. If servletPath is <code>null</code> then
-     * <code>null</code> is returned.
+     * Combine the servletPath and the pathInfo. If pathInfo is <code>null</code> it is ignored. If servletPath is
+     * <code>null</code> then <code>null</code> is returned.
+     *
      * @return The combined path with pathInfo appended to servletInfo
      */
     private String getCombinedPath() {
@@ -490,23 +456,20 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * Include the response from another resource in the current response.
-     * Any runtime exception, IOException, or ServletException thrown by the
-     * called servlet will be propagated to the caller.
+     * Include the response from another resource in the current response. Any runtime exception, IOException, or
+     * ServletException thrown by the called servlet will be propagated to the caller.
      *
-     * @param request The servlet request that is including this one
+     * @param request  The servlet request that is including this one
      * @param response The servlet response to be appended to
      *
-     * @exception IOException if an input/output error occurs
+     * @exception IOException      if an input/output error occurs
      * @exception ServletException if a servlet exception occurs
      */
     @Override
-    public void include(ServletRequest request, ServletResponse response)
-        throws ServletException, IOException
-    {
+    public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException {
         if (Globals.IS_SECURITY_ENABLED) {
             try {
-                PrivilegedInclude dp = new PrivilegedInclude(request,response);
+                PrivilegedInclude dp = new PrivilegedInclude(request, response);
                 AccessController.doPrivileged(dp);
             } catch (PrivilegedActionException pe) {
                 Exception e = pe.getException();
@@ -521,8 +484,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         }
     }
 
-    private void doInclude(ServletRequest request, ServletResponse response)
-            throws ServletException, IOException {
+    private void doInclude(ServletRequest request, ServletResponse response) throws ServletException, IOException {
 
         // Set up to handle the specified request and response
         State state = new State(request, response, true);
@@ -551,8 +513,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         // Handle an HTTP path based include
         else {
 
-            ApplicationHttpRequest wrequest =
-                (ApplicationHttpRequest) wrapRequest(state);
+            ApplicationHttpRequest wrequest = (ApplicationHttpRequest) wrapRequest(state);
             String contextPath = context.getPath();
             if (requestURI != null) {
                 wrequest.setAttribute(RequestDispatcher.INCLUDE_REQUEST_URI, requestURI);
@@ -574,10 +535,8 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
                 wrequest.setAttribute(INCLUDE_MAPPING, mapping);
             }
 
-            wrequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR,
-                    DispatcherType.INCLUDE);
-            wrequest.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR,
-                    getCombinedPath());
+            wrequest.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.INCLUDE);
+            wrequest.setAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR, getCombinedPath());
             invoke(state.outerRequest, state.outerResponse, state);
         }
 
@@ -585,11 +544,10 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     @Override
-    public void dispatch(ServletRequest request, ServletResponse response)
-            throws ServletException, IOException {
+    public void dispatch(ServletRequest request, ServletResponse response) throws ServletException, IOException {
         if (Globals.IS_SECURITY_ENABLED) {
             try {
-                PrivilegedDispatch dp = new PrivilegedDispatch(request,response);
+                PrivilegedDispatch dp = new PrivilegedDispatch(request, response);
                 AccessController.doPrivileged(dp);
             } catch (PrivilegedActionException pe) {
                 Exception e = pe.getException();
@@ -604,8 +562,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         }
     }
 
-    private void doDispatch(ServletRequest request, ServletResponse response)
-            throws ServletException, IOException {
+    private void doDispatch(ServletRequest request, ServletResponse response) throws ServletException, IOException {
 
         // Set up to handle the specified request and response
         State state = new State(request, response, false);
@@ -638,22 +595,20 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * Ask the resource represented by this RequestDispatcher to process
-     * the associated request, and create (or append to) the associated
-     * response.
+     * Ask the resource represented by this RequestDispatcher to process the associated request, and create (or append
+     * to) the associated response.
      * <p>
-     * <strong>IMPLEMENTATION NOTE</strong>: This implementation assumes
-     * that no filters are applied to a forwarded or included resource,
-     * because they were already done for the original request.
+     * <strong>IMPLEMENTATION NOTE</strong>: This implementation assumes that no filters are applied to a forwarded or
+     * included resource, because they were already done for the original request.
      *
-     * @param request The servlet request we are processing
+     * @param request  The servlet request we are processing
      * @param response The servlet response we are creating
      *
-     * @exception IOException if an input/output error occurs
+     * @exception IOException      if an input/output error occurs
      * @exception ServletException if a servlet error occurs
      */
-    private void invoke(ServletRequest request, ServletResponse response,
-            State state) throws IOException, ServletException {
+    private void invoke(ServletRequest request, ServletResponse response, State state)
+            throws IOException, ServletException {
 
         // Checking to see if the context classloader is the current context
         // classloader. If it's not, we're saving it, and setting the context
@@ -670,9 +625,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
         // Check for the servlet being marked unavailable
         if (wrapper.isUnavailable()) {
-            wrapper.getLogger().warn(
-                    sm.getString("applicationDispatcher.isUnavailable",
-                    wrapper.getName()));
+            wrapper.getLogger().warn(sm.getString("applicationDispatcher.isUnavailable", wrapper.getName()));
             long available = wrapper.getAvailable();
             if ((available > 0L) && (available < Long.MAX_VALUE)) {
                 hresponse.setDateHeader("Retry-After", available);
@@ -688,51 +641,45 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
                 servlet = wrapper.allocate();
             }
         } catch (ServletException e) {
-            wrapper.getLogger().error(sm.getString("applicationDispatcher.allocateException",
-                             wrapper.getName()), StandardWrapper.getRootCause(e));
+            wrapper.getLogger().error(sm.getString("applicationDispatcher.allocateException", wrapper.getName()),
+                    StandardWrapper.getRootCause(e));
             servletException = e;
         } catch (Throwable e) {
             ExceptionUtils.handleThrowable(e);
-            wrapper.getLogger().error(sm.getString("applicationDispatcher.allocateException",
-                             wrapper.getName()), e);
-            servletException = new ServletException
-                (sm.getString("applicationDispatcher.allocateException",
-                              wrapper.getName()), e);
+            wrapper.getLogger().error(sm.getString("applicationDispatcher.allocateException", wrapper.getName()), e);
+            servletException = new ServletException(
+                    sm.getString("applicationDispatcher.allocateException", wrapper.getName()), e);
             servlet = null;
         }
 
         // Get the FilterChain Here
-        ApplicationFilterChain filterChain =
-                ApplicationFilterFactory.createFilterChain(request, wrapper, servlet);
+        ApplicationFilterChain filterChain = ApplicationFilterFactory.createFilterChain(request, wrapper, servlet);
 
         // Call the service() method for the allocated servlet instance
         try {
             // for includes/forwards
             if ((servlet != null) && (filterChain != null)) {
-               filterChain.doFilter(request, response);
-             }
+                filterChain.doFilter(request, response);
+            }
             // Servlet Service Method is called by the FilterChain
         } catch (ClientAbortException e) {
             ioException = e;
         } catch (IOException e) {
-            wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException",
-                             wrapper.getName()), e);
+            wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException", wrapper.getName()), e);
             ioException = e;
         } catch (UnavailableException e) {
-            wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException",
-                             wrapper.getName()), e);
+            wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException", wrapper.getName()), e);
             servletException = e;
             wrapper.unavailable(e);
         } catch (ServletException e) {
             Throwable rootCause = StandardWrapper.getRootCause(e);
             if (!(rootCause instanceof ClientAbortException)) {
-                wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException",
-                        wrapper.getName()), rootCause);
+                wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException", wrapper.getName()),
+                        rootCause);
             }
             servletException = e;
         } catch (RuntimeException e) {
-            wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException",
-                             wrapper.getName()), e);
+            wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException", wrapper.getName()), e);
             runtimeException = e;
         }
 
@@ -747,16 +694,13 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
                 wrapper.deallocate(servlet);
             }
         } catch (ServletException e) {
-            wrapper.getLogger().error(sm.getString("applicationDispatcher.deallocateException",
-                             wrapper.getName()), e);
+            wrapper.getLogger().error(sm.getString("applicationDispatcher.deallocateException", wrapper.getName()), e);
             servletException = e;
         } catch (Throwable e) {
             ExceptionUtils.handleThrowable(e);
-            wrapper.getLogger().error(sm.getString("applicationDispatcher.deallocateException",
-                             wrapper.getName()), e);
-            servletException = new ServletException
-                (sm.getString("applicationDispatcher.deallocateException",
-                              wrapper.getName()), e);
+            wrapper.getLogger().error(sm.getString("applicationDispatcher.deallocateException", wrapper.getName()), e);
+            servletException = new ServletException(
+                    sm.getString("applicationDispatcher.deallocateException", wrapper.getName()), e);
         }
 
         // Reset the old context class loader
@@ -808,8 +752,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
             // Remove the current request if it is our wrapper
             if (current == state.wrapRequest) {
-                ServletRequest next =
-                  ((ServletRequestWrapper) current).getRequest();
+                ServletRequest next = ((ServletRequestWrapper) current).getRequest();
                 if (previous == null) {
                     state.outerRequest = next;
                 } else {
@@ -852,8 +795,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
             // Remove the current response if it is our wrapper
             if (current == state.wrapResponse) {
-                ServletResponse next =
-                  ((ServletResponseWrapper) current).getResponse();
+                ServletResponse next = ((ServletResponseWrapper) current).getResponse();
                 if (previous == null) {
                     state.outerResponse = next;
                 } else {
@@ -872,8 +814,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * Create and return a request wrapper that has been inserted in the
-     * appropriate spot in the request chain.
+     * Create and return a request wrapper that has been inserted in the appropriate spot in the request chain.
      */
     private ServletRequest wrapRequest(State state) {
 
@@ -881,8 +822,8 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         ServletRequest previous = null;
         ServletRequest current = state.outerRequest;
         while (current != null) {
-            if(state.hrequest == null && (current instanceof HttpServletRequest)) {
-                state.hrequest = (HttpServletRequest)current;
+            if (state.hrequest == null && (current instanceof HttpServletRequest)) {
+                state.hrequest = (HttpServletRequest) current;
             }
             if (!(current instanceof ServletRequestWrapper)) {
                 break;
@@ -899,27 +840,22 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
         // Instantiate a new wrapper at this point and insert it in the chain
         ServletRequest wrapper = null;
-        if ((current instanceof ApplicationHttpRequest) ||
-            (current instanceof Request) ||
-            (current instanceof HttpServletRequest)) {
+        if ((current instanceof ApplicationHttpRequest) || (current instanceof Request) ||
+                (current instanceof HttpServletRequest)) {
             // Compute a crossContext flag
             HttpServletRequest hcurrent = (HttpServletRequest) current;
             boolean crossContext = false;
-            if ((state.outerRequest instanceof ApplicationHttpRequest) ||
-                (state.outerRequest instanceof Request) ||
-                (state.outerRequest instanceof HttpServletRequest)) {
-                HttpServletRequest houterRequest =
-                    (HttpServletRequest) state.outerRequest;
-                Object contextPath = houterRequest.getAttribute(
-                        RequestDispatcher.INCLUDE_CONTEXT_PATH);
+            if ((state.outerRequest instanceof ApplicationHttpRequest) || (state.outerRequest instanceof Request) ||
+                    (state.outerRequest instanceof HttpServletRequest)) {
+                HttpServletRequest houterRequest = (HttpServletRequest) state.outerRequest;
+                Object contextPath = houterRequest.getAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH);
                 if (contextPath == null) {
                     // Forward
                     contextPath = houterRequest.getContextPath();
                 }
                 crossContext = !(context.getPath().equals(contextPath));
             }
-            wrapper = new ApplicationHttpRequest
-                (hcurrent, context, crossContext);
+            wrapper = new ApplicationHttpRequest(hcurrent, context, crossContext);
         } else {
             wrapper = new ApplicationRequest(current);
         }
@@ -935,8 +871,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
 
     /**
-     * Create and return a response wrapper that has been inserted in the
-     * appropriate spot in the response chain.
+     * Create and return a response wrapper that has been inserted in the appropriate spot in the response chain.
      */
     private ServletResponse wrapResponse(State state) {
 
@@ -945,7 +880,7 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         ServletResponse current = state.outerResponse;
         while (current != null) {
             if (state.hresponse == null && (current instanceof HttpServletResponse)) {
-                state.hresponse = (HttpServletResponse)current;
+                state.hresponse = (HttpServletResponse) current;
                 if (!state.including) { // Forward only needs hresponse
                     return null;
                 }
@@ -981,12 +916,9 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
 
     }
 
-    private void checkSameObjects(ServletRequest appRequest,
-            ServletResponse appResponse) throws ServletException {
-        ServletRequest originalRequest =
-            ApplicationFilterChain.getLastServicedRequest();
-        ServletResponse originalResponse =
-            ApplicationFilterChain.getLastServicedResponse();
+    private void checkSameObjects(ServletRequest appRequest, ServletResponse appResponse) throws ServletException {
+        ServletRequest originalRequest = ApplicationFilterChain.getLastServicedRequest();
+        ServletResponse originalResponse = ApplicationFilterChain.getLastServicedResponse();
 
         // Some forwards, eg from valves will not set original values
         if (originalRequest == null || originalResponse == null) {
@@ -996,61 +928,55 @@ final class ApplicationDispatcher implements AsyncDispatcher, RequestDispatcher
         boolean same = false;
         ServletRequest dispatchedRequest = appRequest;
 
-        //find the request that was passed into the service method
+        // find the request that was passed into the service method
         while (originalRequest instanceof ServletRequestWrapper &&
-                ((ServletRequestWrapper) originalRequest).getRequest()!=null ) {
-            originalRequest =
-                ((ServletRequestWrapper) originalRequest).getRequest();
+                ((ServletRequestWrapper) originalRequest).getRequest() != null) {
+            originalRequest = ((ServletRequestWrapper) originalRequest).getRequest();
         }
-        //compare with the dispatched request
+        // compare with the dispatched request
         while (!same) {
             if (originalRequest.equals(dispatchedRequest)) {
                 same = true;
             }
             if (!same && dispatchedRequest instanceof ServletRequestWrapper) {
-                dispatchedRequest =
-                    ((ServletRequestWrapper) dispatchedRequest).getRequest();
+                dispatchedRequest = ((ServletRequestWrapper) dispatchedRequest).getRequest();
             } else {
                 break;
             }
         }
         if (!same) {
-            throw new ServletException(sm.getString(
-                    "applicationDispatcher.specViolation.request"));
+            throw new ServletException(sm.getString("applicationDispatcher.specViolation.request"));
         }
 
         same = false;
         ServletResponse dispatchedResponse = appResponse;
 
-        //find the response that was passed into the service method
+        // find the response that was passed into the service method
         while (originalResponse instanceof ServletResponseWrapper &&
-                ((ServletResponseWrapper) originalResponse).getResponse() !=
-                    null ) {
-            originalResponse =
-                ((ServletResponseWrapper) originalResponse).getResponse();
+                ((ServletResponseWrapper) originalResponse).getResponse() != null) {
+            originalResponse = ((ServletResponseWrapper) originalResponse).getResponse();
         }
-        //compare with the dispatched response
+        // compare with the dispatched response
         while (!same) {
             if (originalResponse.equals(dispatchedResponse)) {
                 same = true;
             }
 
             if (!same && dispatchedResponse instanceof ServletResponseWrapper) {
-                dispatchedResponse =
-                    ((ServletResponseWrapper) dispatchedResponse).getResponse();
+                dispatchedResponse = ((ServletResponseWrapper) dispatchedResponse).getResponse();
             } else {
                 break;
             }
         }
 
         if (!same) {
-            throw new ServletException(sm.getString(
-                    "applicationDispatcher.specViolation.response"));
+            throw new ServletException(sm.getString("applicationDispatcher.specViolation.response"));
         }
     }
 
     private void recycleRequestWrapper(State state) {
         if (state.wrapRequest instanceof ApplicationHttpRequest) {
-            ((ApplicationHttpRequest) state.wrapRequest).recycle();        }
+            ((ApplicationHttpRequest) state.wrapRequest).recycle();
+        }
     }
 }
diff --git a/java/org/apache/catalina/core/ApplicationFilterChain.java b/java/org/apache/catalina/core/ApplicationFilterChain.java
index 9342ed0438..c10e4eaa24 100644
--- a/java/org/apache/catalina/core/ApplicationFilterChain.java
+++ b/java/org/apache/catalina/core/ApplicationFilterChain.java
@@ -36,11 +36,9 @@ import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
- * Implementation of <code>javax.servlet.FilterChain</code> used to manage
- * the execution of a set of filters for a particular request.  When the
- * set of defined filters has all been executed, the next call to
- * <code>doFilter()</code> will execute the servlet's <code>service()</code>
- * method itself.
+ * Implementation of <code>javax.servlet.FilterChain</code> used to manage the execution of a set of filters for a
+ * particular request. When the set of defined filters has all been executed, the next call to <code>doFilter()</code>
+ * will execute the servlet's <code>service()</code> method itself.
  *
  * @author Craig R. McClanahan
  */
@@ -75,8 +73,7 @@ public final class ApplicationFilterChain implements FilterChain {
 
 
     /**
-     * The int which is used to maintain the current position
-     * in the filter chain.
+     * The int which is used to maintain the current position in the filter chain.
      */
     private int pos = 0;
 
@@ -105,52 +102,45 @@ public final class ApplicationFilterChain implements FilterChain {
 
 
     /**
-     * Static class array used when the SecurityManager is turned on and
-     * <code>doFilter</code> is invoked.
+     * Static class array used when the SecurityManager is turned on and <code>doFilter</code> is invoked.
      */
-    private static final Class<?>[] classType = new Class[]{
-        ServletRequest.class, ServletResponse.class, FilterChain.class};
+    private static final Class<?>[] classType = new Class[] { ServletRequest.class, ServletResponse.class,
+            FilterChain.class };
 
     /**
-     * Static class array used when the SecurityManager is turned on and
-     * <code>service</code> is invoked.
+     * Static class array used when the SecurityManager is turned on and <code>service</code> is invoked.
      */
-    private static final Class<?>[] classTypeUsedInService = new Class[]{
-        ServletRequest.class, ServletResponse.class};
+    private static final Class<?>[] classTypeUsedInService = new Class[] { ServletRequest.class,
+            ServletResponse.class };
 
 
     // ---------------------------------------------------- FilterChain Methods
 
     /**
-     * Invoke the next filter in this chain, passing the specified request
-     * and response.  If there are no more filters in this chain, invoke
-     * the <code>service()</code> method of the servlet itself.
+     * Invoke the next filter in this chain, passing the specified request and response. If there are no more filters in
+     * this chain, invoke the <code>service()</code> method of the servlet itself.
      *
-     * @param request The servlet request we are processing
+     * @param request  The servlet request we are processing
      * @param response The servlet response we are creating
      *
-     * @exception IOException if an input/output error occurs
+     * @exception IOException      if an input/output error occurs
      * @exception ServletException if a servlet exception occurs
      */
     @Override
-    public void doFilter(ServletRequest request, ServletResponse response)
-        throws IOException, ServletException {
+    public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
 
-        if( Globals.IS_SECURITY_ENABLED ) {
+        if (Globals.IS_SECURITY_ENABLED) {
             final ServletRequest req = request;
             final ServletResponse res = response;
             try {
-                java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedExceptionAction<Void>() {
-                        @Override
-                        public Void run()
-                            throws ServletException, IOException {
-                            internalDoFilter(req,res);
-                            return null;
-                        }
+                java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<Void>() {
+                    @Override
+                    public Void run() throws ServletException, IOException {
+                        internalDoFilter(req, res);
+                        return null;
                     }
-                );
-            } catch( PrivilegedActionException pe) {
+                });
+            } catch (PrivilegedActionException pe) {
                 Exception e = pe.getException();
                 if (e instanceof ServletException) {
                     throw (ServletException) e;
@@ -163,13 +153,12 @@ public final class ApplicationFilterChain implements FilterChain {
                 }
             }
         } else {
-            internalDoFilter(request,response);
+            internalDoFilter(request, response);
         }
     }
 
-    private void internalDoFilter(ServletRequest request,
-                                  ServletResponse response)
-        throws IOException, ServletException {
+    private void internalDoFilter(ServletRequest request, ServletResponse response)
+            throws IOException, ServletException {
 
         // Call the next filter if there is one
         if (pos < n) {
@@ -177,18 +166,17 @@ public final class ApplicationFilterChain implements FilterChain {
             try {
                 Filter filter = filterConfig.getFilter();
 
-                if (request.isAsyncSupported() && "false".equalsIgnoreCase(
-                        filterConfig.getFilterDef().getAsyncSupported())) {
+                if (request.isAsyncSupported() &&
+                        "false".equalsIgnoreCase(filterConfig.getFilterDef().getAsyncSupported())) {
                     request.setAttribute(Globals.ASYNC_SUPPORTED_ATTR, Boolean.FALSE);
                 }
-                if( Globals.IS_SECURITY_ENABLED ) {
+                if (Globals.IS_SECURITY_ENABLED) {
                     final ServletRequest req = request;
                     final ServletResponse res = response;
-                    Principal principal =
-                        ((HttpServletRequest) req).getUserPrincipal();
+                    Principal principal = ((HttpServletRequest) req).getUserPrincipal();
 
-                    Object[] args = new Object[]{req, res, this};
-                    SecurityUtil.doAsPrivilege ("doFilter", filter, classType, args, principal);
+                    Object[] args = new Object[] { req, res, this };
+                    SecurityUtil.doAsPrivilege("doFilter", filter, classType, args, principal);
                 } else {
                     filter.doFilter(request, response, this);
                 }
@@ -210,23 +198,16 @@ public final class ApplicationFilterChain implements FilterChain {
             }
 
             if (request.isAsyncSupported() && !servletSupportsAsync) {
-                request.setAttribute(Globals.ASYNC_SUPPORTED_ATTR,
-                        Boolean.FALSE);
+                request.setAttribute(Globals.ASYNC_SUPPORTED_ATTR, Boolean.FALSE);
             }
             // Use potentially wrapped request from this point
-            if ((request instanceof HttpServletRequest) &&
-                    (response instanceof HttpServletResponse) &&
-                    Globals.IS_SECURITY_ENABLED ) {
+            if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse) &&
+                    Globals.IS_SECURITY_ENABLED) {
                 final ServletRequest req = request;
                 final ServletResponse res = response;
-                Principal principal =
-                    ((HttpServletRequest) req).getUserPrincipal();
-                Object[] args = new Object[]{req, res};
-                SecurityUtil.doAsPrivilege("service",
-                                           servlet,
-                                           classTypeUsedInService,
-                                           args,
-                                           principal);
+                Principal principal = ((HttpServletRequest) req).getUserPrincipal();
+                Object[] args = new Object[] { req, res };
+                SecurityUtil.doAsPrivilege("service", servlet, classTypeUsedInService, args, principal);
             } else {
                 servlet.service(request, response);
             }
@@ -246,8 +227,7 @@ public final class ApplicationFilterChain implements FilterChain {
 
 
     /**
-     * The last request passed to a servlet for servicing from the current
-     * thread.
+     * The last request passed to a servlet for servicing from the current thread.
      *
      * @return The last request to be serviced.
      */
@@ -257,8 +237,7 @@ public final class ApplicationFilterChain implements FilterChain {
 
 
     /**
-     * The last response passed to a servlet for servicing from the current
-     * thread.
+     * The last response passed to a servlet for servicing from the current thread.
      *
      * @return The last response to be serviced.
      */
@@ -277,15 +256,14 @@ public final class ApplicationFilterChain implements FilterChain {
     void addFilter(ApplicationFilterConfig filterConfig) {
 
         // Prevent the same filter being added multiple times
-        for(ApplicationFilterConfig filter:filters) {
-            if(filter==filterConfig) {
+        for (ApplicationFilterConfig filter : filters) {
+            if (filter == filterConfig) {
                 return;
             }
         }
 
         if (n == filters.length) {
-            ApplicationFilterConfig[] newFilters =
-                new ApplicationFilterConfig[n + INCREMENT];
+            ApplicationFilterConfig[] newFilters = new ApplicationFilterConfig[n + INCREMENT];
             System.arraycopy(filters, 0, newFilters, 0, n);
             filters = newFilters;
         }
@@ -332,15 +310,13 @@ public final class ApplicationFilterChain implements FilterChain {
 
 
     /**
-     * Identifies the Filters, if any, in this FilterChain that do not support
-     * async.
+     * Identifies the Filters, if any, in this FilterChain that do not support async.
      *
-     * @param result The Set to which the fully qualified class names of each
-     *               Filter in this FilterChain that does not support async will
-     *               be added
+     * @param result The Set to which the fully qualified class names of each Filter in this FilterChain that does not
+     *                   support async will be added
      */
     public void findNonAsyncFilters(Set<String> result) {
-        for (int i = 0; i < n ; i++) {
+        for (int i = 0; i < n; i++) {
             ApplicationFilterConfig filter = filters[i];
             if ("false".equalsIgnoreCase(filter.getFilterDef().getAsyncSupported())) {
                 result.add(filter.getFilterClass());
diff --git a/java/org/apache/catalina/core/ApplicationFilterConfig.java b/java/org/apache/catalina/core/ApplicationFilterConfig.java
index 33e76a400c..1c00cf00bc 100644
--- a/java/org/apache/catalina/core/ApplicationFilterConfig.java
+++ b/java/org/apache/catalina/core/ApplicationFilterConfig.java
@@ -47,9 +47,8 @@ import org.apache.tomcat.util.res.StringManager;
 
 
 /**
- * Implementation of a <code>javax.servlet.FilterConfig</code> useful in
- * managing the filter instances instantiated when a web application
- * is first started.
+ * Implementation of a <code>javax.servlet.FilterConfig</code> useful in managing the filter instances instantiated when
+ * a web application is first started.
  *
  * @author Craig R. McClanahan
  */
@@ -70,34 +69,27 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
 
 
     /**
-     * Construct a new ApplicationFilterConfig for the specified filter
-     * definition.
+     * Construct a new ApplicationFilterConfig for the specified filter definition.
      *
-     * @param context The context with which we are associated
-     * @param filterDef Filter definition for which a FilterConfig is to be
-     *  constructed
+     * @param context   The context with which we are associated
+     * @param filterDef Filter definition for which a FilterConfig is to be constructed
      *
-     * @exception ClassCastException if the specified class does not implement
-     *  the <code>javax.servlet.Filter</code> interface
+     * @exception ClassCastException     if the specified class does not implement the <code>javax.servlet.Filter</code>
+     *                                       interface
      * @exception ClassNotFoundException if the filter class cannot be found
-     * @exception IllegalAccessException if the filter class cannot be
-     *  publicly instantiated
-     * @exception InstantiationException if an exception occurs while
-     *  instantiating the filter object
-     * @exception ServletException if thrown by the filter's init() method
-     * @throws NamingException If a JNDI lookup fails
-     * @throws InvocationTargetException If an error occurs initialising the
-     *         filter
-     * @throws SecurityException If a security manager prevents the creation
-     * @throws NoSuchMethodException If the constructor for the filter cannot
-     *         be found
-     * @throws IllegalArgumentException If the provided configuration is not
-     *         valid
+     * @exception IllegalAccessException if the filter class cannot be publicly instantiated
+     * @exception InstantiationException if an exception occurs while instantiating the filter object
+     * @exception ServletException       if thrown by the filter's init() method
+     *
+     * @throws NamingException           If a JNDI lookup fails
+     * @throws InvocationTargetException If an error occurs initialising the filter
+     * @throws SecurityException         If a security manager prevents the creation
+     * @throws NoSuchMethodException     If the constructor for the filter cannot be found
+     * @throws IllegalArgumentException  If the provided configuration is not valid
      */
-    ApplicationFilterConfig(Context context, FilterDef filterDef)
-            throws ClassCastException, ClassNotFoundException, IllegalAccessException,
-            InstantiationException, ServletException, InvocationTargetException, NamingException,
-            IllegalArgumentException, NoSuchMethodException, SecurityException {
+    ApplicationFilterConfig(Context context, FilterDef filterDef) throws ClassCastException, ClassNotFoundException,
+            IllegalAccessException, InstantiationException, ServletException, InvocationTargetException,
+            NamingException, IllegalArgumentException, NoSuchMethodException, SecurityException {
 
         super();
 
@@ -163,16 +155,15 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
     }
 
     /**
-     * Return a <code>String</code> containing the value of the named
-     * initialization parameter, or <code>null</code> if the parameter
-     * does not exist.
+     * Return a <code>String</code> containing the value of the named initialization parameter, or <code>null</code> if
+     * the parameter does not exist.
      *
      * @param name Name of the requested initialization parameter
      */
     @Override
     public String getInitParameter(String name) {
 
-        Map<String,String> map = filterDef.getParameterMap();
+        Map<String, String> map = filterDef.getParameterMap();
         if (map == null) {
             return null;
         }
@@ -183,12 +174,11 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
 
 
     /**
-     * Return an <code>Enumeration</code> of the names of the initialization
-     * parameters for this Filter.
+     * Return an <code>Enumeration</code> of the names of the initialization parameters for this Filter.
      */
     @Override
     public Enumeration<String> getInitParameterNames() {
-        Map<String,String> map = filterDef.getParameterMap();
+        Map<String, String> map = filterDef.getParameterMap();
 
         if (map == null) {
             return Collections.enumeration(emptyString);
@@ -235,22 +225,18 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
     /**
      * Return the application Filter we are configured for.
      *
-     * @exception ClassCastException if the specified class does not implement
-     *  the <code>javax.servlet.Filter</code> interface
+     * @exception ClassCastException     if the specified class does not implement the <code>javax.servlet.Filter</code>
+     *                                       interface
      * @exception ClassNotFoundException if the filter class cannot be found
-     * @exception IllegalAccessException if the filter class cannot be
-     *  publicly instantiated
-     * @exception InstantiationException if an exception occurs while
-     *  instantiating the filter object
-     * @exception ServletException if thrown by the filter's init() method
-     * @throws NamingException If a JNDI lookup fails
-     * @throws InvocationTargetException If an error occurs initialising the
-     *         filter
-     * @throws SecurityException If a security manager prevents the creation
-     * @throws NoSuchMethodException If the constructor for the filter cannot
-     *         be found
-     * @throws IllegalArgumentException If the provided configuration is not
-     *         valid
+     * @exception IllegalAccessException if the filter class cannot be publicly instantiated
+     * @exception InstantiationException if an exception occurs while instantiating the filter object
+     * @exception ServletException       if thrown by the filter's init() method
+     *
+     * @throws NamingException           If a JNDI lookup fails
+     * @throws InvocationTargetException If an error occurs initialising the filter
+     * @throws SecurityException         If a security manager prevents the creation
+     * @throws NoSuchMethodException     If the constructor for the filter cannot be found
+     * @throws IllegalArgumentException  If the provided configuration is not valid
      */
     Filter getFilter() throws ClassCastException, ClassNotFoundException, IllegalAccessException,
             InstantiationException, ServletException, InvocationTargetException, NamingException,
@@ -272,8 +258,7 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
     }
 
     private void initFilter() throws ServletException {
-        if (context instanceof StandardContext &&
-                context.getSwallowOutput()) {
+        if (context instanceof StandardContext && context.getSwallowOutput()) {
             try {
                 SystemLogHandler.startCapture();
                 filter.init(this);
@@ -299,8 +284,7 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
     }
 
     /**
-     * Release the Filter instance associated with this FilterConfig,
-     * if there is one.
+     * Release the Filter instance associated with this FilterConfig, if there is one.
      */
     void release() {
 
@@ -319,27 +303,23 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
                 }
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
-                context.getLogger().error(sm.getString(
-                        "applicationFilterConfig.release",
-                        filterDef.getFilterName(),
+                context.getLogger().error(sm.getString("applicationFilterConfig.release", filterDef.getFilterName(),
                         filterDef.getFilterClass()), t);
             }
             if (!context.getIgnoreAnnotations()) {
                 try {
                     ((StandardContext) context).getInstanceManager().destroyInstance(this.filter);
                 } catch (Exception e) {
-                    Throwable t = ExceptionUtils
-                            .unwrapInvocationTargetException(e);
+                    Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
                     ExceptionUtils.handleThrowable(t);
-                    context.getLogger().error(
-                            sm.getString("applicationFilterConfig.preDestroy",
-                                    filterDef.getFilterName(), filterDef.getFilterClass()), t);
+                    context.getLogger().error(sm.getString("applicationFilterConfig.preDestroy",
+                            filterDef.getFilterName(), filterDef.getFilterClass()), t);
                 }
             }
         }
         this.filter = null;
 
-     }
+    }
 
 
     // -------------------------------------------------------- Private Methods
@@ -347,11 +327,9 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
     private InstanceManager getInstanceManager() {
         if (instanceManager == null) {
             if (context instanceof StandardContext) {
-                instanceManager = ((StandardContext)context).getInstanceManager();
+                instanceManager = ((StandardContext) context).getInstanceManager();
             } else {
-                instanceManager = new DefaultInstanceManager(null,
-                        new HashMap<String, Map<String, String>>(),
-                        context,
+                instanceManager = new DefaultInstanceManager(null, new HashMap<String, Map<String, String>>(), context,
                         getClass().getClassLoader());
             }
         }
@@ -378,20 +356,16 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
         }
         if (context instanceof StandardContext) {
             StandardContext standardContext = (StandardContext) context;
-            onameStr = domain + ":j2eeType=Filter,WebModule=" + webMod +
-                    ",name=" + filterName + ",J2EEApplication=" +
-                    standardContext.getJ2EEApplication() + ",J2EEServer=" +
-                    standardContext.getJ2EEServer();
+            onameStr = domain + ":j2eeType=Filter,WebModule=" + webMod + ",name=" + filterName + ",J2EEApplication=" +
+                    standardContext.getJ2EEApplication() + ",J2EEServer=" + standardContext.getJ2EEServer();
         } else {
-            onameStr = domain + ":j2eeType=Filter,name=" + filterName +
-                 ",WebModule=" + webMod;
+            onameStr = domain + ":j2eeType=Filter,name=" + filterName + ",WebModule=" + webMod;
         }
         try {
             oname = new ObjectName(onameStr);
             Registry.getRegistry(null, null).registerComponent(this, oname, null);
         } catch (Exception ex) {
-            log.warn(sm.getString("applicationFilterConfig.jmxRegisterFail",
-                    getFilterClass(), getFilterName()), ex);
+            log.warn(sm.getString("applicationFilterConfig.jmxRegisterFail", getFilterClass(), getFilterName()), ex);
         }
     }
 
@@ -402,12 +376,11 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
             try {
                 Registry.getRegistry(null, null).unregisterComponent(oname);
                 if (log.isDebugEnabled()) {
-                    log.debug(sm.getString("applicationFilterConfig.jmxUnregister",
-                            getFilterClass(), getFilterName()));
+                    log.debug(sm.getString("applicationFilterConfig.jmxUnregister", getFilterClass(), getFilterName()));
                 }
-            } catch(Exception ex) {
-                log.warn(sm.getString("applicationFilterConfig.jmxUnregisterFail",
-                        getFilterClass(), getFilterName()), ex);
+            } catch (Exception ex) {
+                log.warn(sm.getString("applicationFilterConfig.jmxUnregisterFail", getFilterClass(), getFilterName()),
+                        ex);
             }
         }
     }
diff --git a/java/org/apache/catalina/core/ApplicationFilterFactory.java b/java/org/apache/catalina/core/ApplicationFilterFactory.java
index 3f3ddee995..daea8d7746 100644
--- a/java/org/apache/catalina/core/ApplicationFilterFactory.java
+++ b/java/org/apache/catalina/core/ApplicationFilterFactory.java
@@ -26,8 +26,7 @@ import org.apache.catalina.connector.Request;
 import org.apache.tomcat.util.descriptor.web.FilterMap;
 
 /**
- * Factory for the creation and caching of Filters and creation
- * of Filter Chains.
+ * Factory for the creation and caching of Filters and creation of Filter Chains.
  *
  * @author Greg Murray
  * @author Remy Maucherat
@@ -40,18 +39,15 @@ public final class ApplicationFilterFactory {
 
 
     /**
-     * Construct a FilterChain implementation that will wrap the execution of
-     * the specified servlet instance.
+     * Construct a FilterChain implementation that will wrap the execution of the specified servlet instance.
      *
      * @param request The servlet request we are processing
      * @param wrapper The wrapper managing the servlet instance
      * @param servlet The servlet instance to be wrapped
      *
-     * @return The configured FilterChain instance or null if none is to be
-     *         executed.
+     * @return The configured FilterChain instance or null if none is to be executed.
      */
-    public static ApplicationFilterChain createFilterChain(ServletRequest request,
-            Wrapper wrapper, Servlet servlet) {
+    public static ApplicationFilterChain createFilterChain(ServletRequest request, Wrapper wrapper, Servlet servlet) {
 
         // If there is no servlet to execute, return null
         if (servlet == null) {
@@ -90,12 +86,11 @@ public final class ApplicationFilterFactory {
         }
 
         // Acquire the information we will need to match filter mappings
-        DispatcherType dispatcher =
-                (DispatcherType) request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
+        DispatcherType dispatcher = (DispatcherType) request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
 
         String requestPath = null;
         Object attribute = request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR);
-        if (attribute != null){
+        if (attribute != null) {
             requestPath = attribute.toString();
         }
 
@@ -109,8 +104,8 @@ public final class ApplicationFilterFactory {
             if (!matchFiltersURL(filterMap, requestPath)) {
                 continue;
             }
-            ApplicationFilterConfig filterConfig = (ApplicationFilterConfig)
-                    context.findFilterConfig(filterMap.getFilterName());
+            ApplicationFilterConfig filterConfig = (ApplicationFilterConfig) context
+                    .findFilterConfig(filterMap.getFilterName());
             if (filterConfig == null) {
                 // FIXME - log configuration problem
                 continue;
@@ -126,8 +121,8 @@ public final class ApplicationFilterFactory {
             if (!matchFiltersServlet(filterMap, servletName)) {
                 continue;
             }
-            ApplicationFilterConfig filterConfig = (ApplicationFilterConfig)
-                    context.findFilterConfig(filterMap.getFilterName());
+            ApplicationFilterConfig filterConfig = (ApplicationFilterConfig) context
+                    .findFilterConfig(filterMap.getFilterName());
             if (filterConfig == null) {
                 // FIXME - log configuration problem
                 continue;
@@ -144,11 +139,10 @@ public final class ApplicationFilterFactory {
 
 
     /**
-     * Return <code>true</code> if the context-relative request path
-     * matches the requirements of the specified filter mapping;
-     * otherwise, return <code>false</code>.
+     * Return <code>true</code> if the context-relative request path matches the requirements of the specified filter
+     * mapping; otherwise, return <code>false</code>.
      *
-     * @param filterMap Filter mapping being checked
+     * @param filterMap   Filter mapping being checked
      * @param requestPath Context-relative request path of this request
      */
     private static boolean matchFiltersURL(FilterMap filterMap, String requestPath) {
@@ -179,11 +173,10 @@ public final class ApplicationFilterFactory {
 
 
     /**
-     * Return <code>true</code> if the context-relative request path
-     * matches the requirements of the specified filter mapping;
-     * otherwise, return <code>false</code>.
+     * Return <code>true</code> if the context-relative request path matches the requirements of the specified filter
+     * mapping; otherwise, return <code>false</code>.
      *
-     * @param testPath URL mapping being checked
+     * @param testPath    URL mapping being checked
      * @param requestPath Context-relative request path of this request
      */
     private static boolean matchFiltersURL(String testPath, String requestPath) {
@@ -202,8 +195,7 @@ public final class ApplicationFilterFactory {
             return true;
         }
         if (testPath.endsWith("/*")) {
-            if (testPath.regionMatches(0, requestPath, 0,
-                                       testPath.length() - 2)) {
+            if (testPath.regionMatches(0, requestPath, 0, testPath.length() - 2)) {
                 if (requestPath.length() == (testPath.length() - 2)) {
                     return true;
                 } else if ('/' == requestPath.charAt(testPath.length() - 2)) {
@@ -217,12 +209,9 @@ public final class ApplicationFilterFactory {
         if (testPath.startsWith("*.")) {
             int slash = requestPath.lastIndexOf('/');
             int period = requestPath.lastIndexOf('.');
-            if ((slash >= 0) && (period > slash)
-                && (period != requestPath.length() - 1)
-                && ((requestPath.length() - period)
-                    == (testPath.length() - 1))) {
-                return testPath.regionMatches(2, requestPath, period + 1,
-                                               testPath.length() - 2);
+            if ((slash >= 0) && (period > slash) && (period != requestPath.length() - 1) &&
+                    ((requestPath.length() - period) == (testPath.length() - 1))) {
+                return testPath.regionMatches(2, requestPath, period + 1, testPath.length() - 2);
             }
         }
 
@@ -233,15 +222,13 @@ public final class ApplicationFilterFactory {
 
 
     /**
-     * Return <code>true</code> if the specified servlet name matches
-     * the requirements of the specified filter mapping; otherwise
-     * return <code>false</code>.
+     * Return <code>true</code> if the specified servlet name matches the requirements of the specified filter mapping;
+     * otherwise return <code>false</code>.
      *
-     * @param filterMap Filter mapping being checked
+     * @param filterMap   Filter mapping being checked
      * @param servletName Servlet name being checked
      */
-    private static boolean matchFiltersServlet(FilterMap filterMap,
-                                        String servletName) {
+    private static boolean matchFiltersServlet(FilterMap filterMap, String servletName) {
 
         if (servletName == null) {
             return false;
@@ -263,32 +250,32 @@ public final class ApplicationFilterFactory {
 
 
     /**
-     * Convenience method which returns true if  the dispatcher type
-     * matches the dispatcher types specified in the FilterMap
+     * Convenience method which returns true if the dispatcher type matches the dispatcher types specified in the
+     * FilterMap
      */
     private static boolean matchDispatcher(FilterMap filterMap, DispatcherType type) {
         switch (type) {
-            case FORWARD :
+            case FORWARD:
                 if ((filterMap.getDispatcherMapping() & FilterMap.FORWARD) != 0) {
                     return true;
                 }
                 break;
-            case INCLUDE :
+            case INCLUDE:
                 if ((filterMap.getDispatcherMapping() & FilterMap.INCLUDE) != 0) {
                     return true;
                 }
                 break;
-            case REQUEST :
+            case REQUEST:
                 if ((filterMap.getDispatcherMapping() & FilterMap.REQUEST) != 0) {
                     return true;
                 }
                 break;
-            case ERROR :
+            case ERROR:
                 if ((filterMap.getDispatcherMapping() & FilterMap.ERROR) != 0) {
                     return true;
                 }
                 break;
-            case ASYNC :
+            case ASYNC:
                 if ((filterMap.getDispatcherMapping() & FilterMap.ASYNC) != 0) {
                     return true;
                 }
diff --git a/java/org/apache/catalina/core/ApplicationFilterRegistration.java b/java/org/apache/catalina/core/ApplicationFilterRegistration.java
index ef8fe6020d..c1f5714385 100644
--- a/java/org/apache/catalina/core/ApplicationFilterRegistration.java
+++ b/java/org/apache/catalina/core/ApplicationFilterRegistration.java
@@ -42,16 +42,14 @@ public class ApplicationFilterRegistration implements FilterRegistration.Dynamic
     private final FilterDef filterDef;
     private final Context context;
 
-    public ApplicationFilterRegistration(FilterDef filterDef,
-            Context context) {
+    public ApplicationFilterRegistration(FilterDef filterDef, Context context) {
         this.filterDef = filterDef;
         this.context = context;
 
     }
 
     @Override
-    public void addMappingForServletNames(
-            EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+    public void addMappingForServletNames(EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
             String... servletNames) {
 
         FilterMap filterMap = new FilterMap();
@@ -79,8 +77,7 @@ public class ApplicationFilterRegistration implements FilterRegistration.Dynamic
     }
 
     @Override
-    public void addMappingForUrlPatterns(
-            EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
+    public void addMappingForUrlPatterns(EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter,
             String... urlPatterns) {
 
         FilterMap filterMap = new FilterMap();
@@ -140,7 +137,7 @@ public class ApplicationFilterRegistration implements FilterRegistration.Dynamic
     @Override
     public String getClassName() {
         return filterDef.getFilterClass();
-   }
+    }
 
     @Override
     public String getInitParameter(String name) {
@@ -149,7 +146,7 @@ public class ApplicationFilterRegistration implements FilterRegistration.Dynamic
 
     @Override
     public Map<String, String> getInitParameters() {
-        ParameterMap<String,String> result = new ParameterMap<>();
+        ParameterMap<String, String> result = new ParameterMap<>();
         result.putAll(filterDef.getParameterMap());
         result.setLocked(true);
         return result;
@@ -164,8 +161,7 @@ public class ApplicationFilterRegistration implements FilterRegistration.Dynamic
     public boolean setInitParameter(String name, String value) {
         if (name == null || value == null) {
             throw new IllegalArgumentException(
-                    sm.getString("applicationFilterRegistration.nullInitParam",
-                            name, value));
+                    sm.getString("applicationFilterRegistration.nullInitParam", name, value));
         }
         if (getInitParameter(name) != null) {
             return false;
@@ -183,9 +179,8 @@ public class ApplicationFilterRegistration implements FilterRegistration.Dynamic
 
         for (Map.Entry<String, String> entry : initParameters.entrySet()) {
             if (entry.getKey() == null || entry.getValue() == null) {
-                throw new IllegalArgumentException(sm.getString(
-                        "applicationFilterRegistration.nullInitParams",
-                                entry.getKey(), entry.getValue()));
+                throw new IllegalArgumentException(
+                        sm.getString("applicationFilterRegistration.nullInitParams", entry.getKey(), entry.getValue()));
             }
             if (getInitParameter(entry.getKey()) != null) {
                 conflicts.add(entry.getKey());
diff --git a/java/org/apache/catalina/core/ApplicationHttpRequest.java b/java/org/apache/catalina/core/ApplicationHttpRequest.java
index 0411d8dcbc..4747bc82ea 100644
--- a/java/org/apache/catalina/core/ApplicationHttpRequest.java
+++ b/java/org/apache/catalina/core/ApplicationHttpRequest.java
@@ -51,16 +51,14 @@ import org.apache.tomcat.util.res.StringManager;
 
 
 /**
- * Wrapper around a <code>javax.servlet.http.HttpServletRequest</code>
- * that transforms an application request object (which might be the original
- * one passed to a servlet, or might be based on the 2.3
- * <code>javax.servlet.http.HttpServletRequestWrapper</code> class)
- * back into an internal <code>org.apache.catalina.HttpRequest</code>.
+ * Wrapper around a <code>javax.servlet.http.HttpServletRequest</code> that transforms an application request object
+ * (which might be the original one passed to a servlet, or might be based on the 2.3
+ * <code>javax.servlet.http.HttpServletRequestWrapper</code> class) back into an internal
+ * <code>org.apache.catalina.HttpRequest</code>.
  * <p>
- * <strong>WARNING</strong>:  Due to Java's lack of support for multiple
- * inheritance, all of the logic in <code>ApplicationRequest</code> is
- * duplicated in <code>ApplicationHttpRequest</code>.  Make sure that you
- * keep these two classes in synchronization when making changes!
+ * <strong>WARNING</strong>: Due to Java's lack of support for multiple inheritance, all of the logic in
+ * <code>ApplicationRequest</code> is duplicated in <code>ApplicationHttpRequest</code>. Make sure that you keep these
+ * two classes in synchronization when making changes!
  *
  * @author Craig R. McClanahan
  * @author Remy Maucherat
@@ -72,19 +70,13 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
     /**
      * The set of attribute names that are special for request dispatchers.
      */
-    protected static final String specials[] =
-    { RequestDispatcher.INCLUDE_REQUEST_URI,
-      RequestDispatcher.INCLUDE_CONTEXT_PATH,
-      RequestDispatcher.INCLUDE_SERVLET_PATH,
-      RequestDispatcher.INCLUDE_PATH_INFO,
-      RequestDispatcher.INCLUDE_QUERY_STRING,
-      ApplicationDispatcher.INCLUDE_MAPPING,
-      RequestDispatcher.FORWARD_REQUEST_URI,
-      RequestDispatcher.FORWARD_CONTEXT_PATH,
-      RequestDispatcher.FORWARD_SERVLET_PATH,
-      RequestDispatcher.FORWARD_PATH_INFO,
-      RequestDispatcher.FORWARD_QUERY_STRING,
-      ApplicationDispatcher.FORWARD_MAPPING};
+    protected static final String specials[] = { RequestDispatcher.INCLUDE_REQUEST_URI,
+            RequestDispatcher.INCLUDE_CONTEXT_PATH, RequestDispatcher.INCLUDE_SERVLET_PATH,
+            RequestDispatcher.INCLUDE_PATH_INFO, RequestDispatcher.INCLUDE_QUERY_STRING,
+            ApplicationDispatcher.INCLUDE_MAPPING, RequestDispatcher.FORWARD_REQUEST_URI,
+            RequestDispatcher.FORWARD_CONTEXT_PATH, RequestDispatcher.FORWARD_SERVLET_PATH,
+            RequestDispatcher.FORWARD_PATH_INFO, RequestDispatcher.FORWARD_QUERY_STRING,
+            ApplicationDispatcher.FORWARD_MAPPING };
 
     private static final int SPECIALS_FIRST_FORWARD_INDEX = 6;
 
@@ -95,13 +87,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
     /**
      * Construct a new wrapped request around the specified servlet request.
      *
-     * @param request The servlet request being wrapped
-     * @param context The target context for the wrapped request
-     * @param crossContext {@code true} if the wrapped request will be a
-     *                     cross-context request, otherwise {@code false}
+     * @param request      The servlet request being wrapped
+     * @param context      The target context for the wrapped request
+     * @param crossContext {@code true} if the wrapped request will be a cross-context request, otherwise {@code false}
      */
-    public ApplicationHttpRequest(HttpServletRequest request, Context context,
-                                  boolean crossContext) {
+    public ApplicationHttpRequest(HttpServletRequest request, Context context, boolean crossContext) {
 
         super(request);
         this.context = context;
@@ -127,8 +117,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * If this request is cross context, since this changes session access
-     * behavior.
+     * If this request is cross context, since this changes session access behavior.
      */
     protected final boolean crossContext;
 
@@ -140,8 +129,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * The request parameters for this request.  This is initialized from the
-     * wrapped request.
+     * The request parameters for this request. This is initialized from the wrapped request.
      */
     protected Map<String, String[]> parameters = null;
 
@@ -228,7 +216,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
         if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
             return dispatcherType;
         } else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
-            if ( requestDispatcherPath != null ){
+            if (requestDispatcherPath != null) {
                 return requestDispatcherPath.toString();
             } else {
                 return null;
@@ -239,8 +227,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
         if (pos == -1) {
             return getRequest().getAttribute(name);
         } else {
-            if ((specialAttributes[pos] == null) &&
-                    (specialAttributes[SPECIALS_FIRST_FORWARD_INDEX] == null) &&
+            if ((specialAttributes[pos] == null) && (specialAttributes[SPECIALS_FIRST_FORWARD_INDEX] == null) &&
                     (pos >= SPECIALS_FIRST_FORWARD_INDEX)) {
                 // If it's a forward special attribute, and null, it means this
                 // is an include, so we check the wrapped request since
@@ -255,8 +242,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getAttributeNames()</code> method of the wrapped
-     * request.
+     * Override the <code>getAttributeNames()</code> method of the wrapped request.
      */
     @Override
     public Enumeration<String> getAttributeNames() {
@@ -265,8 +251,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>removeAttribute()</code> method of the
-     * wrapped request.
+     * Override the <code>removeAttribute()</code> method of the wrapped request.
      *
      * @param name Name of the attribute to remove
      */
@@ -281,17 +266,16 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>setAttribute()</code> method of the
-     * wrapped request.
+     * Override the <code>setAttribute()</code> method of the wrapped request.
      *
-     * @param name Name of the attribute to set
+     * @param name  Name of the attribute to set
      * @param value Value of the attribute to set
      */
     @Override
     public void setAttribute(String name, Object value) {
 
         if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
-            dispatcherType = (DispatcherType)value;
+            dispatcherType = (DispatcherType) value;
             return;
         } else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
             requestDispatcherPath = value;
@@ -306,8 +290,8 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Return a RequestDispatcher that wraps the resource at the specified
-     * path, which may be interpreted as relative to the current request path.
+     * Return a RequestDispatcher that wraps the resource at the specified path, which may be interpreted as relative to
+     * the current request path.
      *
      * @param path Path of the resource to be wrapped
      */
@@ -334,8 +318,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
         }
 
         // Convert a request-relative path to a context-relative one
-        String servletPath =
-            (String) getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
+        String servletPath = (String) getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH);
         if (servletPath == null) {
             servletPath = getServletPath();
         }
@@ -354,8 +337,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
         String relative = null;
         if (context.getDispatchersUseEncodedPaths()) {
             if (pos >= 0) {
-                relative = URLEncoder.DEFAULT.encode(
-                        requestPath.substring(0, pos + 1), StandardCharsets.UTF_8) + path;
+                relative = URLEncoder.DEFAULT.encode(requestPath.substring(0, pos + 1), StandardCharsets.UTF_8) + path;
             } else {
                 relative = URLEncoder.DEFAULT.encode(requestPath, StandardCharsets.UTF_8) + path;
             }
@@ -374,7 +356,6 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
     /**
      * Override the getDispatcherType() method of the wrapped request.
-     *
      */
     @Override
     public DispatcherType getDispatcherType() {
@@ -386,8 +367,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getContextPath()</code> method of the wrapped
-     * request.
+     * Override the <code>getContextPath()</code> method of the wrapped request.
      */
     @Override
     public String getContextPath() {
@@ -413,8 +393,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getParameterMap()</code> method of the
-     * wrapped request.
+     * Override the <code>getParameterMap()</code> method of the wrapped request.
      */
     @Override
     public Map<String, String[]> getParameterMap() {
@@ -424,8 +403,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getParameterNames()</code> method of the
-     * wrapped request.
+     * Override the <code>getParameterNames()</code> method of the wrapped request.
      */
     @Override
     public Enumeration<String> getParameterNames() {
@@ -435,8 +413,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getParameterValues()</code> method of the
-     * wrapped request.
+     * Override the <code>getParameterValues()</code> method of the wrapped request.
      *
      * @param name Name of the requested parameter
      */
@@ -457,8 +434,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getPathTranslated()</code> method of the wrapped
-     * request.
+     * Override the <code>getPathTranslated()</code> method of the wrapped request.
      */
     @Override
     public String getPathTranslated() {
@@ -471,8 +447,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getQueryString()</code> method of the wrapped
-     * request.
+     * Override the <code>getQueryString()</code> method of the wrapped request.
      */
     @Override
     public String getQueryString() {
@@ -481,8 +456,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getRequestURI()</code> method of the wrapped
-     * request.
+     * Override the <code>getRequestURI()</code> method of the wrapped request.
      */
     @Override
     public String getRequestURI() {
@@ -491,8 +465,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getRequestURL()</code> method of the wrapped
-     * request.
+     * Override the <code>getRequestURL()</code> method of the wrapped request.
      */
     @Override
     public StringBuffer getRequestURL() {
@@ -500,16 +473,14 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
         StringBuffer url = new StringBuffer();
         String scheme = getScheme();
         int port = getServerPort();
-        if (port < 0)
-         {
+        if (port < 0) {
             port = 80; // Work around java.net.URL bug
         }
 
         url.append(scheme);
         url.append("://");
         url.append(getServerName());
-        if ((scheme.equals("http") && (port != 80))
-            || (scheme.equals("https") && (port != 443))) {
+        if ((scheme.equals("http") && (port != 80)) || (scheme.equals("https") && (port != 443))) {
             url.append(':');
             url.append(port);
         }
@@ -521,8 +492,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Override the <code>getServletPath()</code> method of the wrapped
-     * request.
+     * Override the <code>getServletPath()</code> method of the wrapped request.
      */
     @Override
     public String getServletPath() {
@@ -536,8 +506,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Return the session associated with this Request, creating one
-     * if necessary.
+     * Return the session associated with this Request, creating one if necessary.
      */
     @Override
     public HttpSession getSession() {
@@ -546,8 +515,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Return the session associated with this Request, creating one
-     * if necessary and requested.
+     * Return the session associated with this Request, creating one if necessary and requested.
      *
      * @param create Create a new session if one does not exist
      */
@@ -576,8 +544,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
             if (other != null) {
                 Session localSession = null;
                 try {
-                    localSession =
-                        context.getManager().findSession(other.getId());
+                    localSession = context.getManager().findSession(other.getId());
                     if (localSession != null && !localSession.isValid()) {
                         localSession = null;
                     }
@@ -585,8 +552,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
                     // Ignore
                 }
                 if (localSession == null && create) {
-                    localSession =
-                        context.getManager().createSession(other.getId());
+                    localSession = context.getManager().createSession(other.getId());
                 }
                 if (localSession != null) {
                     localSession.access();
@@ -604,11 +570,11 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Returns true if the request specifies a JSESSIONID that is valid within
-     * the context of this ApplicationHttpRequest, false otherwise.
+     * Returns true if the request specifies a JSESSIONID that is valid within the context of this
+     * ApplicationHttpRequest, false otherwise.
      *
-     * @return true if the request specifies a JSESSIONID that is valid within
-     * the context of this ApplicationHttpRequest, false otherwise.
+     * @return true if the request specifies a JSESSIONID that is valid within the context of this
+     *             ApplicationHttpRequest, false otherwise.
      */
     @Override
     public boolean isRequestedSessionIdValid() {
@@ -715,7 +681,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
         super.setRequest(request);
 
         // Initialize the attributes for this request
-        dispatcherType = (DispatcherType)request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
+        dispatcherType = (DispatcherType) request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
         requestDispatcherPath = request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR);
 
         // Initialize the path elements for this request
@@ -753,9 +719,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Parses the parameters of this request.
-     *
-     * If parameters are present in both the query string and the request
+     * Parses the parameters of this request. If parameters are present in both the query string and the request
      * content, they are merged.
      */
     void parseParameters() {
@@ -767,7 +731,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
         parameters = new ParameterMap<>();
         parameters.putAll(getRequest().getParameterMap());
         mergeParameters();
-        ((ParameterMap<String,String[]>) parameters).setLocked(true);
+        ((ParameterMap<String, String[]>) parameters).setLocked(true);
         parsedParams = true;
     }
 
@@ -775,8 +739,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
     /**
      * Save query parameters for this request.
      *
-     * @param queryString The query string containing parameters for this
-     *                    request
+     * @param queryString The query string containing parameters for this request
      */
     void setQueryParams(String queryString) {
         this.queryParamString = queryString;
@@ -791,8 +754,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
     // ------------------------------------------------------ Protected Methods
 
     /**
-     * Is this attribute name one of the special ones that is added only for
-     * included servlets?
+     * Is this attribute name one of the special ones that is added only for included servlets?
      *
      * @param name Attribute name to be tested
      */
@@ -811,8 +773,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
     /**
      * Get a special attribute.
      *
-     * @return the special attribute pos, or -1 if it is not a special
-     *         attribute
+     * @return the special attribute pos, or -1 if it is not a special attribute
      */
     protected int getSpecial(String name) {
         for (int i = 0; i < specials.length; i++) {
@@ -886,10 +847,9 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Merge the parameters from the saved query parameter string (if any), and
-     * the parameters already present on this request (if any), such that the
-     * parameter values from the query string show up first if there are
-     * duplicate parameter names.
+     * Merge the parameters from the saved query parameter string (if any), and the parameters already present on this
+     * request (if any), such that the parameter values from the query string show up first if there are duplicate
+     * parameter names.
      */
     private void mergeParameters() {
 
@@ -942,8 +902,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
 
     /**
-     * Utility class used to expose the special attributes as being available
-     * as request attributes.
+     * Utility class used to expose the special attributes as being available as request attributes.
      */
     protected class AttributeNamesEnumerator implements Enumeration<String> {
 
@@ -966,8 +925,7 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
 
         @Override
         public boolean hasMoreElements() {
-            return ((pos != last) || (next != null)
-                    || ((next = findNext()) != null));
+            return ((pos != last) || (next != null) || ((next = findNext()) != null));
         }
 
         @Override
diff --git a/java/org/apache/catalina/core/ApplicationHttpResponse.java b/java/org/apache/catalina/core/ApplicationHttpResponse.java
index 9760a610b8..9c96239191 100644
--- a/java/org/apache/catalina/core/ApplicationHttpResponse.java
+++ b/java/org/apache/catalina/core/ApplicationHttpResponse.java
@@ -25,16 +25,14 @@ import javax.servlet.http.HttpServletResponseWrapper;
 
 
 /**
- * Wrapper around a <code>javax.servlet.http.HttpServletResponse</code>
- * that transforms an application response object (which might be the original
- * one passed to a servlet, or might be based on the 2.3
- * <code>javax.servlet.http.HttpServletResponseWrapper</code> class)
- * back into an internal <code>org.apache.catalina.HttpResponse</code>.
+ * Wrapper around a <code>javax.servlet.http.HttpServletResponse</code> that transforms an application response object
+ * (which might be the original one passed to a servlet, or might be based on the 2.3
+ * <code>javax.servlet.http.HttpServletResponseWrapper</code> class) back into an internal
+ * <code>org.apache.catalina.HttpResponse</code>.
  * <p>
- * <strong>WARNING</strong>:  Due to Java's lack of support for multiple
- * inheritance, all of the logic in <code>ApplicationResponse</code> is
- * duplicated in <code>ApplicationHttpResponse</code>.  Make sure that you
- * keep these two classes in synchronization when making changes!
+ * <strong>WARNING</strong>: Due to Java's lack of support for multiple inheritance, all of the logic in
+ * <code>ApplicationResponse</code> is duplicated in <code>ApplicationHttpResponse</code>. Make sure that you keep these
+ * two classes in synchronization when making changes!
  *
  * @author Craig R. McClanahan
  */
@@ -46,11 +44,10 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
      * Construct a new wrapped response around the specified servlet response.
      *
      * @param response The servlet response being wrapped
-     * @param included <code>true</code> if this response is being processed
-     *  by a <code>RequestDispatcher.include()</code> call
+     * @param included <code>true</code> if this response is being processed by a
+     *                     <code>RequestDispatcher.include()</code> call
      */
-    public ApplicationHttpResponse(HttpServletResponse response,
-                                   boolean included) {
+    public ApplicationHttpResponse(HttpServletResponse response, boolean included) {
 
         super(response);
         setIncluded(included);
@@ -62,8 +59,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
 
 
     /**
-     * Is this wrapped response the subject of an <code>include()</code>
-     * call?
+     * Is this wrapped response the subject of an <code>include()</code> call?
      */
     protected boolean included = false;
 
@@ -73,8 +69,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>reset()</code> calls on a included response.
      *
-     * @exception IllegalStateException if the response has already
-     *  been committed
+     * @exception IllegalStateException if the response has already been committed
      */
     @Override
     public void reset() {
@@ -88,8 +83,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
 
 
     /**
-     * Disallow <code>setContentLength(int)</code> calls on an included
-     * response.
+     * Disallow <code>setContentLength(int)</code> calls on an included response.
      *
      * @param len The new content length
      */
@@ -104,8 +98,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
 
 
     /**
-     * Disallow <code>setContentLengthLong(long)</code> calls on an included
-     * response.
+     * Disallow <code>setContentLengthLong(long)</code> calls on an included response.
      *
      * @param len The new content length
      */
@@ -183,7 +176,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>addDateHeader()</code> calls on an included response.
      *
-     * @param name The new header name
+     * @param name  The new header name
      * @param value The new header value
      */
     @Override
@@ -199,7 +192,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>addHeader()</code> calls on an included response.
      *
-     * @param name The new header name
+     * @param name  The new header name
      * @param value The new header value
      */
     @Override
@@ -215,7 +208,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>addIntHeader()</code> calls on an included response.
      *
-     * @param name The new header name
+     * @param name  The new header name
      * @param value The new header value
      */
     @Override
@@ -248,7 +241,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>sendError()</code> calls on an included response.
      *
-     * @param sc The new status code
+     * @param sc  The new status code
      * @param msg The new message
      *
      * @exception IOException if an input/output error occurs
@@ -283,7 +276,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>setDateHeader()</code> calls on an included response.
      *
-     * @param name The new header name
+     * @param name  The new header name
      * @param value The new header value
      */
     @Override
@@ -299,7 +292,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>setHeader()</code> calls on an included response.
      *
-     * @param name The new header name
+     * @param name  The new header name
      * @param value The new header value
      */
     @Override
@@ -315,7 +308,7 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>setIntHeader()</code> calls on an included response.
      *
-     * @param name The new header name
+     * @param name  The new header name
      * @param value The new header value
      */
     @Override
@@ -346,12 +339,12 @@ class ApplicationHttpResponse extends HttpServletResponseWrapper {
     /**
      * Disallow <code>setStatus()</code> calls on an included response.
      *
-     * @param sc The new status code
+     * @param sc  The new status code
      * @param msg The new message
-     * @deprecated As of version 2.1, due to ambiguous meaning of the message
-     *             parameter. To set a status code use
-     *             <code>setStatus(int)</code>, to send an error with a
-     *             description use <code>sendError(int, String)</code>.
+     *
+     * @deprecated As of version 2.1, due to ambiguous meaning of the message parameter. To set a status code use
+     *                 <code>setStatus(int)</code>, to send an error with a description use
+     *                 <code>sendError(int, String)</code>.
      */
     @Deprecated
     @Override
diff --git a/java/org/apache/catalina/core/ApplicationMappingImpl.java b/java/org/apache/catalina/core/ApplicationMappingImpl.java
index 3922943103..6fe8daa932 100644
--- a/java/org/apache/catalina/core/ApplicationMappingImpl.java
+++ b/java/org/apache/catalina/core/ApplicationMappingImpl.java
@@ -23,7 +23,8 @@ public class ApplicationMappingImpl {
     private final ApplicationMappingMatch mappingType;
     private final String servletName;
 
-    public ApplicationMappingImpl(String matchValue, String pattern, ApplicationMappingMatch mappingType, String servletName) {
+    public ApplicationMappingImpl(String matchValue, String pattern, ApplicationMappingMatch mappingType,
+            String servletName) {
         this.matchValue = matchValue;
         this.pattern = pattern;
         this.mappingType = mappingType;
diff --git a/java/org/apache/catalina/core/ApplicationMappingMatch.java b/java/org/apache/catalina/core/ApplicationMappingMatch.java
index 084d129328..bd98199cf3 100644
--- a/java/org/apache/catalina/core/ApplicationMappingMatch.java
+++ b/java/org/apache/catalina/core/ApplicationMappingMatch.java
@@ -22,14 +22,12 @@ package org.apache.catalina.core;
 public enum ApplicationMappingMatch {
 
     /**
-     * The request was mapped to the servlet via the context root URL pattern of
-     * {@code ""}.
+     * The request was mapped to the servlet via the context root URL pattern of {@code ""}.
      */
     CONTEXT_ROOT,
 
     /**
-     * The request was mapped to the servlet via the default servlet URL pattern
-     * of {@code "/"} .
+     * The request was mapped to the servlet via the default servlet URL pattern of {@code "/"} .
      */
     DEFAULT,
 
@@ -39,8 +37,7 @@ public enum ApplicationMappingMatch {
     EXACT,
 
     /**
-     * The request was mapped to the servlet using an extension URL pattern
-     * match.
+     * The request was mapped to the servlet using an extension URL pattern match.
      */
     EXTENSION,
 
diff --git a/java/org/apache/catalina/core/ApplicationPart.java b/java/org/apache/catalina/core/ApplicationPart.java
index 296de8f176..b21b8a7de0 100644
--- a/java/org/apache/catalina/core/ApplicationPart.java
+++ b/java/org/apache/catalina/core/ApplicationPart.java
@@ -35,9 +35,8 @@ import org.apache.tomcat.util.http.fileupload.disk.DiskFileItem;
 import org.apache.tomcat.util.http.parser.HttpParser;
 
 /**
- * Adaptor to allow {@link FileItem} objects generated by the package renamed
- * commons-upload to be used by the Servlet 3.0 upload API that expects
- * {@link Part}s.
+ * Adaptor to allow {@link FileItem} objects generated by the package renamed commons-upload to be used by the Servlet
+ * 3.0 upload API that expects {@link Part}s.
  */
 public class ApplicationPart implements Part {
 
@@ -71,8 +70,7 @@ public class ApplicationPart implements Part {
     public Collection<String> getHeaderNames() {
         if (fileItem instanceof DiskFileItem) {
             LinkedHashSet<String> headerNames = new LinkedHashSet<>();
-            Iterator<String> iter =
-                ((DiskFileItem) fileItem).getHeaders().getHeaderNames();
+            Iterator<String> iter = ((DiskFileItem) fileItem).getHeaders().getHeaderNames();
             while (iter.hasNext()) {
                 headerNames.add(iter.next());
             }
@@ -85,8 +83,7 @@ public class ApplicationPart implements Part {
     public Collection<String> getHeaders(String name) {
         if (fileItem instanceof DiskFileItem) {
             LinkedHashSet<String> headers = new LinkedHashSet<>();
-            Iterator<String> iter =
-                ((DiskFileItem) fileItem).getHeaders().getHeaders(name);
+            Iterator<String> iter = ((DiskFileItem) fileItem).getHeaders().getHeaders(name);
             while (iter.hasNext()) {
                 headers.add(iter.next());
             }
@@ -140,7 +137,7 @@ public class ApplicationPart implements Part {
                 ParameterParser paramParser = new ParameterParser();
                 paramParser.setLowerCaseNames(true);
                 // Parameter parser can handle null input
-                Map<String,String> params = paramParser.parse(cd, ';');
+                Map<String, String> params = paramParser.parse(cd, ';');
                 if (params.containsKey("filename")) {
                     fileName = params.get("filename");
                     // The parser will remove surrounding '"' but will not
diff --git a/java/org/apache/catalina/core/ApplicationPushBuilder.java b/java/org/apache/catalina/core/ApplicationPushBuilder.java
index 9037e9c95f..f823ac3d1e 100644
--- a/java/org/apache/catalina/core/ApplicationPushBuilder.java
+++ b/java/org/apache/catalina/core/ApplicationPushBuilder.java
@@ -67,7 +67,7 @@ public class ApplicationPushBuilder {
     private final boolean addSessionCookie;
     private final boolean addSessionPathParameter;
 
-    private final Map<String,List<String>> headers = new CaseInsensitiveKeyMap<>();
+    private final Map<String, List<String>> headers = new CaseInsensitiveKeyMap<>();
     private final List<Cookie> cookies = new ArrayList<>();
     private String method = "GET";
     private String path;
@@ -127,10 +127,9 @@ public class ApplicationPushBuilder {
         if (sessionId == null) {
             sessionId = request.getRequestedSessionId();
         }
-        if (!request.isRequestedSessionIdFromCookie() && !request.isRequestedSessionIdFromURL() &&
-                sessionId != null) {
-            Set<SessionTrackingMode> sessionTrackingModes =
-                    request.getServletContext().getEffectiveSessionTrackingModes();
+        if (!request.isRequestedSessionIdFromCookie() && !request.isRequestedSessionIdFromURL() && sessionId != null) {
+            Set<SessionTrackingMode> sessionTrackingModes = request.getServletContext()
+                    .getEffectiveSessionTrackingModes();
             addSessionCookie = sessionTrackingModes.contains(SessionTrackingMode.COOKIE);
             addSessionPathParameter = sessionTrackingModes.contains(SessionTrackingMode.URL);
         } else {
@@ -159,16 +158,15 @@ public class ApplicationPushBuilder {
         }
         if (cookies.size() > 0) {
             List<String> cookieValues = new ArrayList<>(1);
-            cookieValues.add(generateCookieHeader(cookies,
-                    catalinaRequest.getContext().getCookieProcessor()));
+            cookieValues.add(generateCookieHeader(cookies, catalinaRequest.getContext().getCookieProcessor()));
             headers.put("cookie", cookieValues);
         }
 
         // Authentication
         if (catalinaRequest.getPrincipal() != null) {
-            if ((session == null) || catalinaRequest.getSessionInternal(false).getPrincipal() == null
-                    || !(context.getAuthenticator() instanceof AuthenticatorBase)
-                    || !((AuthenticatorBase) context.getAuthenticator()).getCache()) {
+            if ((session == null) || catalinaRequest.getSessionInternal(false).getPrincipal() == null ||
+                    !(context.getAuthenticator() instanceof AuthenticatorBase) ||
+                    !((AuthenticatorBase) context.getAuthenticator()).getCache()) {
                 // Set a username only if there is no session cache for the principal
                 userName = catalinaRequest.getPrincipal().getName();
             }
@@ -201,8 +199,7 @@ public class ApplicationPushBuilder {
     public ApplicationPushBuilder method(String method) {
         String upperMethod = method.trim().toUpperCase(Locale.ENGLISH);
         if (DISALLOWED_METHODS.contains(upperMethod) || upperMethod.length() == 0) {
-            throw new IllegalArgumentException(
-                    sm.getString("applicationPushBuilder.methodInvalid", upperMethod));
+            throw new IllegalArgumentException(sm.getString("applicationPushBuilder.methodInvalid", upperMethod));
         }
         // Check a token was supplied
         if (!HttpParser.isToken(upperMethod)) {
@@ -302,7 +299,7 @@ public class ApplicationPushBuilder {
         pushTarget.scheme().setString(baseRequest.getScheme());
 
         // Copy headers
-        for (Map.Entry<String,List<String>> header : headers.entrySet()) {
+        for (Map.Entry<String, List<String>> header : headers.entrySet()) {
             for (String value : header.getValue()) {
                 pushTarget.getMimeHeaders().addValue(header.getKey()).setString(value);
             }
@@ -341,8 +338,7 @@ public class ApplicationPushBuilder {
 
         // Undecoded path - just %nn encoded
         pushTarget.requestURI().setString(pushPath);
-        pushTarget.decodedURI().setString(decode(pushPath,
-                catalinaRequest.getConnector().getURICharset()));
+        pushTarget.decodedURI().setString(decode(pushPath, catalinaRequest.getConnector().getURICharset()));
 
         // Query string
         if (pushQueryString == null && queryString != null) {
@@ -350,7 +346,7 @@ public class ApplicationPushBuilder {
         } else if (pushQueryString != null && queryString == null) {
             pushTarget.queryString().setString(pushQueryString);
         } else if (pushQueryString != null && queryString != null) {
-            pushTarget.queryString().setString(pushQueryString + "&" +queryString);
+            pushTarget.queryString().setString(pushQueryString + "&" + queryString);
         }
 
         // Authorization
@@ -385,7 +381,7 @@ public class ApplicationPushBuilder {
             result.append(input.substring(end, start));
             // Advance the end 3 characters: %nn
             end = start + 3;
-            while (end <input.length() && input.charAt(end) == '%') {
+            while (end < input.length() && input.charAt(end) == '%') {
                 end += 3;
             }
             result.append(decodePercentSequence(input.substring(start, end), charset));
@@ -399,7 +395,7 @@ public class ApplicationPushBuilder {
 
 
     private static String decodePercentSequence(String sequence, Charset charset) {
-        byte[] bytes = new byte[sequence.length()/3];
+        byte[] bytes = new byte[sequence.length() / 3];
         for (int i = 0; i < bytes.length; i += 3) {
             bytes[i] = (byte) ((HexUtils.getDec(sequence.charAt(1 + 3 * i)) << 4) +
                     HexUtils.getDec(sequence.charAt(2 + 3 * i)));
diff --git a/java/org/apache/catalina/core/ApplicationRequest.java b/java/org/apache/catalina/core/ApplicationRequest.java
index 871c7b24df..ea9f70f469 100644
--- a/java/org/apache/catalina/core/ApplicationRequest.java
+++ b/java/org/apache/catalina/core/ApplicationRequest.java
@@ -27,16 +27,14 @@ import javax.servlet.ServletRequestWrapper;
 
 
 /**
- * Wrapper around a <code>javax.servlet.ServletRequest</code>
- * that transforms an application request object (which might be the original
- * one passed to a servlet, or might be based on the 2.3
- * <code>javax.servlet.ServletRequestWrapper</code> class)
- * back into an internal <code>org.apache.catalina.Request</code>.
+ * Wrapper around a <code>javax.servlet.ServletRequest</code> that transforms an application request object (which might
+ * be the original one passed to a servlet, or might be based on the 2.3
+ * <code>javax.servlet.ServletRequestWrapper</code> class) back into an internal
+ * <code>org.apache.catalina.Request</code>.
  * <p>
- * <strong>WARNING</strong>:  Due to Java's lack of support for multiple
- * inheritance, all of the logic in <code>ApplicationRequest</code> is
- * duplicated in <code>ApplicationHttpRequest</code>.  Make sure that you
- * keep these two classes in synchronization when making changes!
+ * <strong>WARNING</strong>: Due to Java's lack of support for multiple inheritance, all of the logic in
+ * <code>ApplicationRequest</code> is duplicated in <code>ApplicationHttpRequest</code>. Make sure that you keep these
+ * two classes in synchronization when making changes!
  *
  * @author Craig R. McClanahan
  */
@@ -49,17 +47,12 @@ class ApplicationRequest extends ServletRequestWrapper {
     /**
      * The set of attribute names that are special for request dispatchers.
      */
-    protected static final String specials[] =
-    { RequestDispatcher.INCLUDE_REQUEST_URI,
-      RequestDispatcher.INCLUDE_CONTEXT_PATH,
-      RequestDispatcher.INCLUDE_SERVLET_PATH,
-      RequestDispatcher.INCLUDE_PATH_INFO,
-      RequestDispatcher.INCLUDE_QUERY_STRING,
-      RequestDispatcher.FORWARD_REQUEST_URI,
-      RequestDispatcher.FORWARD_CONTEXT_PATH,
-      RequestDispatcher.FORWARD_SERVLET_PATH,
-      RequestDispatcher.FORWARD_PATH_INFO,
-      RequestDispatcher.FORWARD_QUERY_STRING };
+    protected static final String specials[] = { RequestDispatcher.INCLUDE_REQUEST_URI,
+            RequestDispatcher.INCLUDE_CONTEXT_PATH, RequestDispatcher.INCLUDE_SERVLET_PATH,
+            RequestDispatcher.INCLUDE_PATH_INFO, RequestDispatcher.INCLUDE_QUERY_STRING,
+            RequestDispatcher.FORWARD_REQUEST_URI, RequestDispatcher.FORWARD_CONTEXT_PATH,
+            RequestDispatcher.FORWARD_SERVLET_PATH, RequestDispatcher.FORWARD_PATH_INFO,
+            RequestDispatcher.FORWARD_QUERY_STRING };
 
 
     // ----------------------------------------------------------- Constructors
@@ -82,8 +75,7 @@ class ApplicationRequest extends ServletRequestWrapper {
 
 
     /**
-     * The request attributes for this request.  This is initialized from the
-     * wrapped request, but updates are allowed.
+     * The request attributes for this request. This is initialized from the wrapped request, but updates are allowed.
      */
     protected final HashMap<String, Object> attributes = new HashMap<>();
 
@@ -107,8 +99,7 @@ class ApplicationRequest extends ServletRequestWrapper {
 
 
     /**
-     * Override the <code>getAttributeNames()</code> method of the wrapped
-     * request.
+     * Override the <code>getAttributeNames()</code> method of the wrapped request.
      */
     @Override
     public Enumeration<String> getAttributeNames() {
@@ -121,8 +112,7 @@ class ApplicationRequest extends ServletRequestWrapper {
 
 
     /**
-     * Override the <code>removeAttribute()</code> method of the
-     * wrapped request.
+     * Override the <code>removeAttribute()</code> method of the wrapped request.
      *
      * @param name Name of the attribute to remove
      */
@@ -140,10 +130,9 @@ class ApplicationRequest extends ServletRequestWrapper {
 
 
     /**
-     * Override the <code>setAttribute()</code> method of the
-     * wrapped request.
+     * Override the <code>setAttribute()</code> method of the wrapped request.
      *
-     * @param name Name of the attribute to set
+     * @param name  Name of the attribute to set
      * @param value Value of the attribute to set
      */
     @Override
@@ -190,8 +179,7 @@ class ApplicationRequest extends ServletRequestWrapper {
 
 
     /**
-     * Is this attribute name one of the special ones that is added only for
-     * included servlets?
+     * Is this attribute name one of the special ones that is added only for included servlets?
      *
      * @param name Attribute name to be tested
      */
diff --git a/java/org/apache/catalina/core/ApplicationResponse.java b/java/org/apache/catalina/core/ApplicationResponse.java
index 66cc170720..21e2d0c1db 100644
--- a/java/org/apache/catalina/core/ApplicationResponse.java
+++ b/java/org/apache/catalina/core/ApplicationResponse.java
@@ -23,16 +23,14 @@ import javax.servlet.ServletResponseWrapper;
 
 
 /**
- * Wrapper around a <code>javax.servlet.ServletResponse</code>
- * that transforms an application response object (which might be the original
- * one passed to a servlet, or might be based on the 2.3
- * <code>javax.servlet.ServletResponseWrapper</code> class)
- * back into an internal <code>org.apache.catalina.Response</code>.
+ * Wrapper around a <code>javax.servlet.ServletResponse</code> that transforms an application response object (which
+ * might be the original one passed to a servlet, or might be based on the 2.3
+ * <code>javax.servlet.ServletResponseWrapper</code> class) back into an internal
+ * <code>org.apache.catalina.Response</code>.
  * <p>
- * <strong>WARNING</strong>:  Due to Java's lack of support for multiple
- * inheritance, all of the logic in <code>ApplicationResponse</code> is
- * duplicated in <code>ApplicationHttpResponse</code>.  Make sure that you
- * keep these two classes in synchronization when making changes!
+ * <strong>WARNING</strong>: Due to Java's lack of support for multiple inheritance, all of the logic in
+ * <code>ApplicationResponse</code> is duplicated in <code>ApplicationHttpResponse</code>. Make sure that you keep these
+ * two classes in synchronization when making changes!
  *
  * @author Craig R. McClanahan
  */
@@ -44,8 +42,8 @@ class ApplicationResponse extends ServletResponseWrapper {
      * Construct a new wrapped response around the specified servlet response.
      *
      * @param response The servlet response being wrapped
-     * @param included <code>true</code> if this response is being processed
-     *  by a <code>RequestDispatcher.include()</code> call
+     * @param included <code>true</code> if this response is being processed by a
+     *                     <code>RequestDispatcher.include()</code> call
      */
     public ApplicationResponse(ServletResponse response, boolean included) {
 
@@ -59,8 +57,7 @@ class ApplicationResponse extends ServletResponseWrapper {
 
 
     /**
-     * Is this wrapped response the subject of an <code>include()</code>
-     * call?
+     * Is this wrapped response the subject of an <code>include()</code> call?
      */
     protected boolean included = false;
 
@@ -71,8 +68,7 @@ class ApplicationResponse extends ServletResponseWrapper {
     /**
      * Disallow <code>reset()</code> calls on a included response.
      *
-     * @exception IllegalStateException if the response has already
-     *  been committed
+     * @exception IllegalStateException if the response has already been committed
      */
     @Override
     public void reset() {
@@ -86,8 +82,7 @@ class ApplicationResponse extends ServletResponseWrapper {
 
 
     /**
-     * Disallow <code>setContentLength(int)</code> calls on an included
-     * response.
+     * Disallow <code>setContentLength(int)</code> calls on an included response.
      *
      * @param len The new content length
      */
@@ -102,8 +97,7 @@ class ApplicationResponse extends ServletResponseWrapper {
 
 
     /**
-     * Disallow <code>setContentLengthLong(long)</code> calls on an included
-     * response.
+     * Disallow <code>setContentLengthLong(long)</code> calls on an included response.
      *
      * @param len The new content length
      */
diff --git a/java/org/apache/catalina/core/ApplicationServletRegistration.java b/java/org/apache/catalina/core/ApplicationServletRegistration.java
index c4d2c02c4d..9a0d3c96e7 100644
--- a/java/org/apache/catalina/core/ApplicationServletRegistration.java
+++ b/java/org/apache/catalina/core/ApplicationServletRegistration.java
@@ -45,8 +45,7 @@ public class ApplicationServletRegistration implements ServletRegistration.Dynam
     private final Context context;
     private ServletSecurityElement constraint;
 
-    public ApplicationServletRegistration(Wrapper wrapper,
-            Context context) {
+    public ApplicationServletRegistration(Wrapper wrapper, Context context) {
         this.wrapper = wrapper;
         this.context = context;
 
@@ -64,7 +63,7 @@ public class ApplicationServletRegistration implements ServletRegistration.Dynam
 
     @Override
     public Map<String, String> getInitParameters() {
-        ParameterMap<String,String> result = new ParameterMap<>();
+        ParameterMap<String, String> result = new ParameterMap<>();
 
         String[] parameterNames = wrapper.findInitParameters();
 
@@ -85,8 +84,7 @@ public class ApplicationServletRegistration implements ServletRegistration.Dynam
     public boolean setInitParameter(String name, String value) {
         if (name == null || value == null) {
             throw new IllegalArgumentException(
-                    sm.getString("applicationFilterRegistration.nullInitParam",
-                            name, value));
+                    sm.getString("applicationFilterRegistration.nullInitParam", name, value));
         }
         if (getInitParameter(name) != null) {
             return false;
@@ -104,9 +102,8 @@ public class ApplicationServletRegistration implements ServletRegistration.Dynam
 
         for (Map.Entry<String, String> entry : initParameters.entrySet()) {
             if (entry.getKey() == null || entry.getValue() == null) {
-                throw new IllegalArgumentException(sm.getString(
-                        "applicationFilterRegistration.nullInitParams",
-                                entry.getKey(), entry.getValue()));
+                throw new IllegalArgumentException(
+                        sm.getString("applicationFilterRegistration.nullInitParams", entry.getKey(), entry.getValue()));
             }
             if (getInitParameter(entry.getKey()) != null) {
                 conflicts.add(entry.getKey());
@@ -147,14 +144,12 @@ public class ApplicationServletRegistration implements ServletRegistration.Dynam
     @Override
     public Set<String> setServletSecurity(ServletSecurityElement constraint) {
         if (constraint == null) {
-            throw new IllegalArgumentException(sm.getString(
-                    "applicationServletRegistration.setServletSecurity.iae",
+            throw new IllegalArgumentException(sm.getString("applicationServletRegistration.setServletSecurity.iae",
                     getName(), context.getName()));
         }
 
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(
-                    "applicationServletRegistration.setServletSecurity.ise",
+            throw new IllegalStateException(sm.getString("applicationServletRegistration.setServletSecurity.ise",
                     getName(), context.getName()));
         }
 
@@ -190,8 +185,7 @@ public class ApplicationServletRegistration implements ServletRegistration.Dynam
         }
 
         for (String urlPattern : urlPatterns) {
-            context.addServletMappingDecoded(
-                    UDecoder.URLDecode(urlPattern, StandardCharsets.UTF_8), wrapper.getName());
+            context.addServletMappingDecoded(UDecoder.URLDecode(urlPattern, StandardCharsets.UTF_8), wrapper.getName());
         }
 
         if (constraint != null) {
diff --git a/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java b/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java
index 35a316ad16..29b48c5f78 100644
--- a/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java
+++ b/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java
@@ -82,9 +82,8 @@ public class ApplicationSessionCookieConfig implements SessionCookieConfig {
     @Override
     public void setComment(String comment) {
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(
-                    "applicationSessionCookieConfig.ise", "comment",
-                    context.getPath()));
+            throw new IllegalStateException(
+                    sm.getString("applicationSessionCookieConfig.ise", "comment", context.getPath()));
         }
         this.comment = comment;
     }
@@ -92,9 +91,8 @@ public class ApplicationSessionCookieConfig implements SessionCookieConfig {
     @Override
     public void setDomain(String domain) {
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(
-                    "applicationSessionCookieConfig.ise", "domain name",
-                    context.getPath()));
+            throw new IllegalStateException(
+                    sm.getString("applicationSessionCookieConfig.ise", "domain name", context.getPath()));
         }
         this.domain = domain;
     }
@@ -102,9 +100,8 @@ public class ApplicationSessionCookieConfig implements SessionCookieConfig {
     @Override
     public void setHttpOnly(boolean httpOnly) {
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(
-                    "applicationSessionCookieConfig.ise", "HttpOnly",
-                    context.getPath()));
+            throw new IllegalStateException(
+                    sm.getString("applicationSessionCookieConfig.ise", "HttpOnly", context.getPath()));
         }
         this.httpOnly = httpOnly;
     }
@@ -112,9 +109,8 @@ public class ApplicationSessionCookieConfig implements SessionCookieConfig {
     @Override
     public void setMaxAge(int maxAge) {
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(
-                    "applicationSessionCookieConfig.ise", "max age",
-                    context.getPath()));
+            throw new IllegalStateException(
+                    sm.getString("applicationSessionCookieConfig.ise", "max age", context.getPath()));
         }
         this.maxAge = maxAge;
     }
@@ -122,9 +118,8 @@ public class ApplicationSessionCookieConfig implements SessionCookieConfig {
     @Override
     public void setName(String name) {
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(
-                    "applicationSessionCookieConfig.ise", "name",
-                    context.getPath()));
+            throw new IllegalStateException(
+                    sm.getString("applicationSessionCookieConfig.ise", "name", context.getPath()));
         }
         this.name = name;
     }
@@ -132,9 +127,8 @@ public class ApplicationSessionCookieConfig implements SessionCookieConfig {
     @Override
     public void setPath(String path) {
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(
-                    "applicationSessionCookieConfig.ise", "path",
-                    context.getPath()));
+            throw new IllegalStateException(
+                    sm.getString("applicationSessionCookieConfig.ise", "path", context.getPath()));
         }
         this.path = path;
     }
@@ -142,9 +136,8 @@ public class ApplicationSessionCookieConfig implements SessionCookieConfig {
     @Override
     public void setSecure(boolean secure) {
         if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
-            throw new IllegalStateException(sm.getString(
-                    "applicationSessionCookieConfig.ise", "secure",
-                    context.getPath()));
+            throw new IllegalStateException(
+                    sm.getString("applicationSessionCookieConfig.ise", "secure", context.getPath()));
         }
         this.secure = secure;
     }
@@ -152,25 +145,22 @@ public class ApplicationSessionCookieConfig implements SessionCookieConfig {
     /**
      * Creates a new session cookie for the given session ID
      *
-     * @param context     The Context for the web application
-     * @param sessionId   The ID of the session for which the cookie will be
-     *                    created
-     * @param secure      Should session cookie be configured as secure
+     * @param context   The Context for the web application
+     * @param sessionId The ID of the session for which the cookie will be created
+     * @param secure    Should session cookie be configured as secure
+     *
      * @return the cookie for the session
      */
-    public static Cookie createSessionCookie(Context context,
-            String sessionId, boolean secure) {
+    public static Cookie createSessionCookie(Context context, String sessionId, boolean secure) {
 
-        SessionCookieConfig scc =
-            context.getServletContext().getSessionCookieConfig();
+        SessionCookieConfig scc = context.getServletContext().getSessionCookieConfig();
 
         // NOTE: The priority order for session cookie configuration is:
-        //       1. Context level configuration
-        //       2. Values from SessionCookieConfig
-        //       3. Defaults
+        // 1. Context level configuration
+        // 2. Values from SessionCookieConfig
+        // 3. Defaults
 
-        Cookie cookie = new Cookie(
-                SessionConfig.getSessionCookieName(context), sessionId);
+        Cookie cookie = new Cookie(SessionConfig.getSessionCookieName(context), sessionId);
 
         // Just apply the defaults.
         cookie.setMaxAge(scc.getMaxAge());
diff --git a/java/org/apache/catalina/core/AprLifecycleListener.java b/java/org/apache/catalina/core/AprLifecycleListener.java
index 301e3623e2..26970ecd21 100644
--- a/java/org/apache/catalina/core/AprLifecycleListener.java
+++ b/java/org/apache/catalina/core/AprLifecycleListener.java
@@ -34,16 +34,13 @@ import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
- * Implementation of <code>LifecycleListener</code> that will init and
- * and destroy APR.
+ * Implementation of <code>LifecycleListener</code> that will init and and destroy APR.
  * <p>
  * This listener must only be nested within {@link Server} elements.
  * <p>
- * <strong>Note</strong>: If you are running Tomcat in an embedded fashion and
- * have more than one Server instance per JVM, this listener <em>must not</em>
- * be added to the {@code Server} instances, but handled outside by the calling
- * code which is bootstrapping the embedded Tomcat instances. Not doing so will
- * lead to JVM crashes.
+ * <strong>Note</strong>: If you are running Tomcat in an embedded fashion and have more than one Server instance per
+ * JVM, this listener <em>must not</em> be added to the {@code Server} instances, but handled outside by the calling
+ * code which is bootstrapping the embedded Tomcat instances. Not doing so will lead to JVM crashes.
  *
  * @since 4.1
  */
@@ -54,9 +51,8 @@ public class AprLifecycleListener implements LifecycleListener {
     private static boolean instanceCreated = false;
 
     /**
-     * Info messages during init() are cached until Lifecycle.BEFORE_INIT_EVENT
-     * so that, in normal (non-error) cases, init() related log messages appear
-     * at the expected point in the lifecycle.
+     * Info messages during init() are cached until Lifecycle.BEFORE_INIT_EVENT so that, in normal (non-error) cases,
+     * init() related log messages appear at the expected point in the lifecycle.
      */
     private static final List<String> initInfoLogMessages = new ArrayList<>(3);
 
@@ -83,7 +79,7 @@ public class AprLifecycleListener implements LifecycleListener {
     private static int tcnPatch = 0;
     private static int tcnVersion = 0;
 
-    protected static String SSLEngine = "on"; //default on
+    protected static String SSLEngine = "on"; // default on
     protected static String FIPSMode = "off"; // default off, valid only when SSLEngine="on"
     protected static String SSLRandomSeed = "builtin";
     protected static boolean sslInitialized = false;
@@ -94,14 +90,13 @@ public class AprLifecycleListener implements LifecycleListener {
     protected static boolean fipsModeActive = false;
 
     /**
-     * The "FIPS mode" level that we use as the argument to OpenSSL method
-     * <code>FIPS_mode_set()</code> to enable FIPS mode and that we expect as
-     * the return value of <code>FIPS_mode()</code> when FIPS mode is enabled.
+     * The "FIPS mode" level that we use as the argument to OpenSSL method <code>FIPS_mode_set()</code> to enable FIPS
+     * mode and that we expect as the return value of <code>FIPS_mode()</code> when FIPS mode is enabled.
      * <p>
-     * In the future the OpenSSL library might grow support for different
-     * non-zero "FIPS" modes that specify different allowed subsets of ciphers
-     * or whatever, but nowadays only "1" is the supported value.
+     * In the future the OpenSSL library might grow support for different non-zero "FIPS" modes that specify different
+     * allowed subsets of ciphers or whatever, but nowadays only "1" is the supported value.
      * </p>
+     *
      * @see <a href="http://wiki.openssl.org/index.php/FIPS_mode_set%28%29">OpenSSL method FIPS_mode_set()</a>
      * @see <a href="http://wiki.openssl.org/index.php/FIPS_mode%28%29">OpenSSL method FIPS_mode()</a>
      */
@@ -112,7 +107,7 @@ public class AprLifecycleListener implements LifecycleListener {
     protected static final Object lock = new Object();
 
     public static boolean isAprAvailable() {
-        //https://bz.apache.org/bugzilla/show_bug.cgi?id=48613
+        // https://bz.apache.org/bugzilla/show_bug.cgi?id=48613
         if (instanceCreated) {
             synchronized (lock) {
                 init();
@@ -138,8 +133,7 @@ public class AprLifecycleListener implements LifecycleListener {
         if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
             synchronized (lock) {
                 if (!(event.getLifecycle() instanceof Server)) {
-                    log.warn(sm.getString("listener.notServer",
-                            event.getLifecycle().getClass().getSimpleName()));
+                    log.warn(sm.getString("listener.notServer", event.getLifecycle().getClass().getSimpleName()));
                 }
                 init();
                 for (String msg : initInfoLogMessages) {
@@ -181,12 +175,11 @@ public class AprLifecycleListener implements LifecycleListener {
 
     }
 
-    private static void terminateAPR() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException,
-            InvocationTargetException {
+    private static void terminateAPR()
+            throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
         String methodName = "terminate";
-        Method method = Class.forName("org.apache.tomcat.jni.Library")
-            .getMethod(methodName, (Class [])null);
-        method.invoke(null, (Object []) null);
+        Method method = Class.forName("org.apache.tomcat.jni.Library").getMethod(methodName, (Class[]) null);
+        method.invoke(null, (Object[]) null);
         aprAvailable = false;
         aprInitialized = false;
         sslInitialized = false; // Well we cleaned the pool in terminate.
@@ -212,12 +205,10 @@ public class AprLifecycleListener implements LifecycleListener {
         } catch (LibraryNotFoundError lnfe) {
             // Library not on path
             if (log.isDebugEnabled()) {
-                log.debug(sm.getString("aprListener.aprInitDebug",
-                        lnfe.getLibraryNames(), System.getProperty("java.library.path"),
-                        lnfe.getMessage()), lnfe);
+                log.debug(sm.getString("aprListener.aprInitDebug", lnfe.getLibraryNames(),
+                        System.getProperty("java.library.path"), lnfe.getMessage()), lnfe);
             }
-            initInfoLogMessages.add(sm.getString("aprListener.aprInit",
-                    System.getProperty("java.library.path")));
+            initInfoLogMessages.add(sm.getString("aprListener.aprInit", System.getProperty("java.library.path")));
             return;
         } catch (Throwable t) {
             // Library present but failed to load
@@ -238,11 +229,8 @@ public class AprLifecycleListener implements LifecycleListener {
             return;
         }
         if (tcnVersion < rqver) {
-            log.error(sm.getString("aprListener.tcnInvalid",
-                    Library.versionString(),
-                    TCN_REQUIRED_MAJOR + "." +
-                    TCN_REQUIRED_MINOR + "." +
-                    TCN_REQUIRED_PATCH));
+            log.error(sm.getString("aprListener.tcnInvalid", Library.versionString(),
+                    TCN_REQUIRED_MAJOR + "." + TCN_REQUIRED_MINOR + "." + TCN_REQUIRED_PATCH));
             try {
                 // Terminate the APR in case the version
                 // is below required.
@@ -254,27 +242,20 @@ public class AprLifecycleListener implements LifecycleListener {
             return;
         }
         if (tcnVersion < rcver) {
-            initInfoLogMessages.add(sm.getString("aprListener.tcnVersion",
-                    Library.versionString(),
-                    TCN_RECOMMENDED_MAJOR + "." +
-                    TCN_RECOMMENDED_MINOR + "." +
-                    TCN_RECOMMENDED_PV));
+            initInfoLogMessages.add(sm.getString("aprListener.tcnVersion", Library.versionString(),
+                    TCN_RECOMMENDED_MAJOR + "." + TCN_RECOMMENDED_MINOR + "." + TCN_RECOMMENDED_PV));
         }
 
-        initInfoLogMessages.add(sm.getString("aprListener.tcnValid",
-                Library.versionString(),
-                Library.aprVersionString()));
+        initInfoLogMessages
+                .add(sm.getString("aprListener.tcnValid", Library.versionString(), Library.aprVersionString()));
 
         // Log APR flags
-        initInfoLogMessages.add(sm.getString("aprListener.flags",
-                Boolean.valueOf(Library.APR_HAVE_IPV6),
-                Boolean.valueOf(Library.APR_HAS_SENDFILE),
-                Boolean.valueOf(Library.APR_HAS_SO_ACCEPTFILTER),
+        initInfoLogMessages.add(sm.getString("aprListener.flags", Boolean.valueOf(Library.APR_HAVE_IPV6),
+                Boolean.valueOf(Library.APR_HAS_SENDFILE), Boolean.valueOf(Library.APR_HAS_SO_ACCEPTFILTER),
                 Boolean.valueOf(Library.APR_HAS_RANDOM)));
 
-        initInfoLogMessages.add(sm.getString("aprListener.config",
-                Boolean.valueOf(useAprConnector),
-                Boolean.valueOf(useOpenSSL)));
+        initInfoLogMessages
+                .add(sm.getString("aprListener.config", Boolean.valueOf(useAprConnector), Boolean.valueOf(useOpenSSL)));
 
         aprAvailable = true;
     }
@@ -302,7 +283,7 @@ public class AprLifecycleListener implements LifecycleListener {
 
 
         methodName = "initialize";
-        paramValues[0] = "on".equalsIgnoreCase(SSLEngine)?null:SSLEngine;
+        paramValues[0] = "on".equalsIgnoreCase(SSLEngine) ? null : SSLEngine;
         method = clazz.getMethod(methodName, paramTypes);
         method.invoke(null, paramValues);
 
@@ -317,7 +298,7 @@ public class AprLifecycleListener implements LifecycleListener {
             final boolean enterFipsMode;
             int fipsModeState = SSL.fipsModeGet();
 
-            if(log.isDebugEnabled()) {
+            if (log.isDebugEnabled()) {
                 log.debug(sm.getString("aprListener.currentFIPSMode", Integer.valueOf(fipsModeState)));
             }
 
@@ -363,13 +344,12 @@ public class AprLifecycleListener implements LifecycleListener {
                         fipsModeActive = true;
                         enterFipsMode = false;
                     } else {
-                        throw new IllegalStateException(sm.getString(
-                                "aprListener.enterAlreadyInFIPSMode", Integer.valueOf(fipsModeState)));
+                        throw new IllegalStateException(
+                                sm.getString("aprListener.enterAlreadyInFIPSMode", Integer.valueOf(fipsModeState)));
                     }
                 }
             } else {
-                throw new IllegalArgumentException(sm.getString(
-                        "aprListener.wrongFIPSMode", FIPSMode));
+                throw new IllegalArgumentException(sm.getString("aprListener.wrongFIPSMode", FIPSMode));
             }
 
             if (enterFipsMode) {
@@ -404,8 +384,7 @@ public class AprLifecycleListener implements LifecycleListener {
         if (!SSLEngine.equals(AprLifecycleListener.SSLEngine)) {
             // Ensure that the SSLEngine is consistent with that used for SSL init
             if (sslInitialized) {
-                throw new IllegalStateException(
-                        sm.getString("aprListener.tooLateForSSLEngine"));
+                throw new IllegalStateException(sm.getString("aprListener.tooLateForSSLEngine"));
             }
 
             AprLifecycleListener.SSLEngine = SSLEngine;
@@ -420,8 +399,7 @@ public class AprLifecycleListener implements LifecycleListener {
         if (!SSLRandomSeed.equals(AprLifecycleListener.SSLRandomSeed)) {
             // Ensure that the random seed is consistent with that used for SSL init
             if (sslInitialized) {
-                throw new IllegalStateException(
-                        sm.getString("aprListener.tooLateForSSLRandomSeed"));
+                throw new IllegalStateException(sm.getString("aprListener.tooLateForSSLRandomSeed"));
             }
 
             AprLifecycleListener.SSLRandomSeed = SSLRandomSeed;
@@ -436,8 +414,7 @@ public class AprLifecycleListener implements LifecycleListener {
         if (!FIPSMode.equals(AprLifecycleListener.FIPSMode)) {
             // Ensure that the FIPS mode is consistent with that used for SSL init
             if (sslInitialized) {
-                throw new IllegalStateException(
-                        sm.getString("aprListener.tooLateForFIPSMode"));
+                throw new IllegalStateException(sm.getString("aprListener.tooLateForFIPSMode"));
             }
 
             AprLifecycleListener.FIPSMode = FIPSMode;
diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java b/java/org/apache/catalina/core/AsyncContextImpl.java
index eb1dcce070..70555d962e 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -55,12 +55,11 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
 
     protected static final StringManager sm = StringManager.getManager(AsyncContextImpl.class);
 
-    /* When a request uses a sequence of multiple start(); dispatch() with
-     * non-container threads it is possible for a previous dispatch() to
-     * interfere with a following start(). This lock prevents that from
-     * happening. It is a dedicated object as user code may lock on the
-     * AsyncContext so if container code also locks on that object deadlocks may
-     * occur.
+    /*
+     * When a request uses a sequence of multiple start(); dispatch() with non-container threads it is possible for a
+     * previous dispatch() to interfere with a following start(). This lock prevents that from happening. It is a
+     * dedicated object as user code may lock on the AsyncContext so if container code also locks on that object
+     * deadlocks may occur.
      */
     private final Object asyncContextLock = new Object();
 
@@ -105,8 +104,7 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
                     listener.fireOnComplete(event);
                 } catch (Throwable t) {
                     ExceptionUtils.handleThrowable(t);
-                    log.warn(sm.getString("asyncContextImpl.onCompleteError",
-                            listener.getClass().getName()), t);
+                    log.warn(sm.getString("asyncContextImpl.onCompleteError", listener.getClass().getName()), t);
                 }
             }
         } finally {
@@ -135,12 +133,10 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
                         listener.fireOnTimeout(event);
                     } catch (Throwable t) {
                         ExceptionUtils.handleThrowable(t);
-                        log.warn(sm.getString("asyncContextImpl.onTimeoutError",
-                                listener.getClass().getName()), t);
+                        log.warn(sm.getString("asyncContextImpl.onTimeoutError", listener.getClass().getName()), t);
                     }
                 }
-                request.getCoyoteRequest().action(
-                        ActionCode.ASYNC_IS_TIMINGOUT, result);
+                request.getCoyoteRequest().action(ActionCode.ASYNC_IS_TIMINGOUT, result);
             } finally {
                 context.unbind(false, oldCL);
             }
@@ -185,10 +181,9 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
             }
             check();
             if (dispatch != null) {
-                throw new IllegalStateException(
-                        sm.getString("asyncContextImpl.dispatchingStarted"));
+                throw new IllegalStateException(sm.getString("asyncContextImpl.dispatchingStarted"));
             }
-            if (request.getAttribute(ASYNC_REQUEST_URI)==null) {
+            if (request.getAttribute(ASYNC_REQUEST_URI) == null) {
                 request.setAttribute(ASYNC_REQUEST_URI, request.getRequestURI());
                 request.setAttribute(ASYNC_CONTEXT_PATH, request.getContextPath());
                 request.setAttribute(ASYNC_SERVLET_PATH, request.getServletPath());
@@ -197,15 +192,12 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
             }
             final RequestDispatcher requestDispatcher = servletContext.getRequestDispatcher(path);
             if (!(requestDispatcher instanceof AsyncDispatcher)) {
-                throw new UnsupportedOperationException(
-                        sm.getString("asyncContextImpl.noAsyncDispatcher"));
+                throw new UnsupportedOperationException(sm.getString("asyncContextImpl.noAsyncDispatcher"));
             }
-            final AsyncDispatcher applicationDispatcher =
-                    (AsyncDispatcher) requestDispatcher;
+            final AsyncDispatcher applicationDispatcher = (AsyncDispatcher) requestDispatcher;
             final ServletRequest servletRequest = getRequest();
             final ServletResponse servletResponse = getResponse();
-            this.dispatch = new AsyncRunnable(
-                    request, applicationDispatcher, servletRequest, servletResponse);
+            this.dispatch = new AsyncRunnable(request, applicationDispatcher, servletRequest, servletResponse);
             this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH, null);
             clearServletRequestResponse();
         }
@@ -215,8 +207,7 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
     public ServletRequest getRequest() {
         check();
         if (servletRequest == null) {
-            throw new IllegalStateException(
-                    sm.getString("asyncContextImpl.request.ise"));
+            throw new IllegalStateException(sm.getString("asyncContextImpl.request.ise"));
         }
         return servletRequest;
     }
@@ -225,8 +216,7 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
     public ServletResponse getResponse() {
         check();
         if (servletResponse == null) {
-            throw new IllegalStateException(
-                    sm.getString("asyncContextImpl.response.ise"));
+            throw new IllegalStateException(sm.getString("asyncContextImpl.response.ise"));
         }
         return servletResponse;
     }
@@ -250,8 +240,7 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
     }
 
     @Override
-    public void addListener(AsyncListener listener, ServletRequest servletRequest,
-            ServletResponse servletResponse) {
+    public void addListener(AsyncListener listener, ServletRequest servletRequest, ServletResponse servletResponse) {
         check();
         AsyncListenerWrapper wrapper = new AsyncListenerWrapper();
         wrapper.setListener(listener);
@@ -262,13 +251,11 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
 
     @SuppressWarnings("unchecked")
     @Override
-    public <T extends AsyncListener> T createListener(Class<T> clazz)
-            throws ServletException {
+    public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException {
         check();
         T listener = null;
         try {
-             listener = (T) context.getInstanceManager().newInstance(
-                     clazz.getName(), clazz.getClassLoader());
+            listener = (T) context.getInstanceManager().newInstance(clazz.getName(), clazz.getClassLoader());
         } catch (ReflectiveOperationException | NamingException e) {
             ServletException se = new ServletException(e);
             throw se;
@@ -301,17 +288,15 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
 
     public boolean isStarted() {
         AtomicBoolean result = new AtomicBoolean(false);
-        request.getCoyoteRequest().action(
-                ActionCode.ASYNC_IS_STARTED, result);
+        request.getCoyoteRequest().action(ActionCode.ASYNC_IS_STARTED, result);
         return result.get();
     }
 
-    public void setStarted(Context context, ServletRequest request,
-            ServletResponse response, boolean originalRequestResponse) {
+    public void setStarted(Context context, ServletRequest request, ServletResponse response,
+            boolean originalRequestResponse) {
 
         synchronized (asyncContextLock) {
-            this.request.getCoyoteRequest().action(
-                    ActionCode.ASYNC_START, this);
+            this.request.getCoyoteRequest().action(ActionCode.ASYNC_START, this);
 
             this.context = context;
             context.incrementInProgressAsyncCount();
@@ -330,8 +315,7 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
                     listener.fireOnStartAsync(event);
                 } catch (Throwable t) {
                     ExceptionUtils.handleThrowable(t);
-                    log.warn(sm.getString("asyncContextImpl.onStartAsyncError",
-                            listener.getClass().getName()), t);
+                    log.warn(sm.getString("asyncContextImpl.onStartAsyncError", listener.getClass().getName()), t);
                 }
             }
         }
@@ -357,10 +341,10 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
         } catch (RuntimeException x) {
             // doInternalComplete(true);
             if (x.getCause() instanceof ServletException) {
-                throw (ServletException)x.getCause();
+                throw (ServletException) x.getCause();
             }
             if (x.getCause() instanceof IOException) {
-                throw (IOException)x.getCause();
+                throw (IOException) x.getCause();
             }
             throw new ServletException(x);
         }
@@ -378,12 +362,10 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
     public void setTimeout(long timeout) {
         check();
         this.timeout = timeout;
-        request.getCoyoteRequest().action(ActionCode.ASYNC_SETTIMEOUT,
-                Long.valueOf(timeout));
+        request.getCoyoteRequest().action(ActionCode.ASYNC_SETTIMEOUT, Long.valueOf(timeout));
     }
 
 
-
     @Override
     public boolean isAvailable() {
         Context context = this.context;
@@ -395,7 +377,7 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
 
 
     public void setErrorState(Throwable t, boolean fireOnError) {
-        if (t!=null) {
+        if (t != null) {
             request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
         }
         request.getCoyoteRequest().action(ActionCode.ASYNC_ERROR, null);
@@ -404,16 +386,15 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
             if (log.isDebugEnabled()) {
                 log.debug(sm.getString("asyncContextImpl.fireOnError"));
             }
-            AsyncEvent errorEvent = new AsyncEvent(event.getAsyncContext(),
-                    event.getSuppliedRequest(), event.getSuppliedResponse(), t);
+            AsyncEvent errorEvent = new AsyncEvent(event.getAsyncContext(), event.getSuppliedRequest(),
+                    event.getSuppliedResponse(), t);
             List<AsyncListenerWrapper> listenersCopy = new ArrayList<>(listeners);
             for (AsyncListenerWrapper listener : listenersCopy) {
                 try {
                     listener.fireOnError(errorEvent);
                 } catch (Throwable t2) {
                     ExceptionUtils.handleThrowable(t2);
-                    log.warn(sm.getString("asyncContextImpl.onErrorError",
-                            listener.getClass().getName()), t2);
+                    log.warn(sm.getString("asyncContextImpl.onErrorError", listener.getClass().getName()), t2);
                 }
             }
         }
@@ -429,19 +410,16 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
             // threads)
             ServletResponse servletResponse = this.servletResponse;
             if (servletResponse instanceof HttpServletResponse) {
-                ((HttpServletResponse) servletResponse).setStatus(
-                        HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                ((HttpServletResponse) servletResponse).setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
             }
 
             Host host = (Host) context.getParent();
             Valve stdHostValve = host.getPipeline().getBasic();
             if (stdHostValve instanceof StandardHostValve) {
-                ((StandardHostValve) stdHostValve).throwable(request,
-                        request.getResponse(), t);
+                ((StandardHostValve) stdHostValve).throwable(request, request.getResponse(), t);
             }
 
-            request.getCoyoteRequest().action(
-                    ActionCode.ASYNC_IS_ERROR, result);
+            request.getCoyoteRequest().action(ActionCode.ASYNC_IS_ERROR, result);
             if (result.get()) {
                 // Still in the error state. The error page did not call
                 // complete() or dispatch(). Complete the async processing.
@@ -506,9 +484,8 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
         }
         String msg = String.format(
                 "Req: %1$8s  CReq: %2$8s  RP: %3$8s  Stage: %4$s  " +
-                "Thread: %5$20s  State: %6$20s  Method: %7$11s  URI: %8$s",
-                rHashCode, crHashCode, rpHashCode, stage,
-                threadName, "N/A", method, uri);
+                        "Thread: %5$20s  State: %6$20s  Method: %7$11s  URI: %8$s",
+                rHashCode, crHashCode, rpHashCode, stage, threadName, "N/A", method, uri);
         if (log.isTraceEnabled()) {
             log.trace(msg, new DebugException());
         } else {
@@ -519,8 +496,7 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
     private void check() {
         if (request == null) {
             // AsyncContext has been recycled and should not be being used
-            throw new IllegalStateException(sm.getString(
-                    "asyncContextImpl.requestEnded"));
+            throw new IllegalStateException(sm.getString("asyncContextImpl.requestEnded"));
         }
     }
 
@@ -534,8 +510,7 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
         private final Context context;
         private final org.apache.coyote.Request coyoteRequest;
 
-        public RunnableWrapper(Runnable wrapped, Context ctxt,
-                org.apache.coyote.Request coyoteRequest) {
+        public RunnableWrapper(Runnable wrapped, Context ctxt, org.apache.coyote.Request coyoteRequest) {
             this.wrapped = wrapped;
             this.context = ctxt;
             this.coyoteRequest = coyoteRequest;
@@ -572,8 +547,8 @@ public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
         private final ServletRequest servletRequest;
         private final ServletResponse servletResponse;
 
-        public AsyncRunnable(Request request, AsyncDispatcher applicationDispatcher,
-                ServletRequest servletRequest, ServletResponse servletResponse) {
+        public AsyncRunnable(Request request, AsyncDispatcher applicationDispatcher, ServletRequest servletRequest,
+                ServletResponse servletResponse) {
             this.request = request;
             this.applicationDispatcher = applicationDispatcher;
             this.servletRequest = servletRequest;
diff --git a/java/org/apache/catalina/core/AsyncListenerWrapper.java b/java/org/apache/catalina/core/AsyncListenerWrapper.java
index 694276d60f..1ed0c858ee 100644
--- a/java/org/apache/catalina/core/AsyncListenerWrapper.java
+++ b/java/org/apache/catalina/core/AsyncListenerWrapper.java
@@ -72,8 +72,7 @@ public class AsyncListenerWrapper {
 
     private AsyncEvent customizeEvent(AsyncEvent event) {
         if (servletRequest != null && servletResponse != null) {
-            return new AsyncEvent(event.getAsyncContext(), servletRequest, servletResponse,
-                    event.getThrowable());
+            return new AsyncEvent(event.getAsyncContext(), servletRequest, servletResponse, event.getThrowable());
         } else {
             return event;
         }
diff --git a/java/org/apache/catalina/core/ContainerBase.java b/java/org/apache/catalina/core/ContainerBase.java
index e3ecd9aaa7..a8516118bd 100644
--- a/java/org/apache/catalina/core/ContainerBase.java
+++ b/java/org/apache/catalina/core/ContainerBase.java
@@ -68,61 +68,56 @@ import org.apache.tomcat.util.res.StringManager;
 
 
 /**
- * Abstract implementation of the <b>Container</b> interface, providing common
- * functionality required by nearly every implementation.  Classes extending
- * this base class must may implement a replacement for <code>invoke()</code>.
+ * Abstract implementation of the <b>Container</b> interface, providing common functionality required by nearly every
+ * implementation. Classes extending this base class must may implement a replacement for <code>invoke()</code>.
  * <p>
- * All subclasses of this abstract base class will include support for a
- * Pipeline object that defines the processing to be performed for each request
- * received by the <code>invoke()</code> method of this class, utilizing the
- * "Chain of Responsibility" design pattern.  A subclass should encapsulate its
- * own processing functionality as a <code>Valve</code>, and configure this
- * Valve into the pipeline by calling <code>setBasic()</code>.
+ * All subclasses of this abstract base class will include support for a Pipeline object that defines the processing to
+ * be performed for each request received by the <code>invoke()</code> method of this class, utilizing the "Chain of
+ * Responsibility" design pattern. A subclass should encapsulate its own processing functionality as a
+ * <code>Valve</code>, and configure this Valve into the pipeline by calling <code>setBasic()</code>.
  * <p>
- * This implementation fires property change events, per the JavaBeans design
- * pattern, for changes in singleton properties.  In addition, it fires the
- * following <code>ContainerEvent</code> events to listeners who register
+ * This implementation fires property change events, per the JavaBeans design pattern, for changes in singleton
+ * properties. In addition, it fires the following <code>ContainerEvent</code> events to listeners who register
  * themselves with <code>addContainerListener()</code>:
  * <table border=1>
- *   <caption>ContainerEvents fired by this implementation</caption>
- *   <tr>
- *     <th>Type</th>
- *     <th>Data</th>
- *     <th>Description</th>
- *   </tr>
- *   <tr>
- *     <td><code>addChild</code></td>
- *     <td><code>Container</code></td>
- *     <td>Child container added to this Container.</td>
- *   </tr>
- *   <tr>
- *     <td><code>{@link #getPipeline() pipeline}.addValve</code></td>
- *     <td><code>Valve</code></td>
- *     <td>Valve added to this Container.</td>
- *   </tr>
- *   <tr>
- *     <td><code>removeChild</code></td>
- *     <td><code>Container</code></td>
- *     <td>Child container removed from this Container.</td>
- *   </tr>
- *   <tr>
- *     <td><code>{@link #getPipeline() pipeline}.removeValve</code></td>
- *     <td><code>Valve</code></td>
- *     <td>Valve removed from this Container.</td>
- *   </tr>
- *   <tr>
- *     <td><code>start</code></td>
- *     <td><code>null</code></td>
- *     <td>Container was started.</td>
- *   </tr>
- *   <tr>
- *     <td><code>stop</code></td>
- *     <td><code>null</code></td>
- *     <td>Container was stopped.</td>
- *   </tr>
+ * <caption>ContainerEvents fired by this implementation</caption>
+ * <tr>
+ * <th>Type</th>
+ * <th>Data</th>
+ * <th>Description</th>
+ * </tr>
+ * <tr>
+ * <td><code>addChild</code></td>
+ * <td><code>Container</code></td>
+ * <td>Child container added to this Container.</td>
+ * </tr>
+ * <tr>
+ * <td><code>{@link #getPipeline() pipeline}.addValve</code></td>
+ * <td><code>Valve</code></td>
+ * <td>Valve added to this Container.</td>
+ * </tr>
+ * <tr>
+ * <td><code>removeChild</code></td>
+ * <td><code>Container</code></td>
+ * <td>Child container removed from this Container.</td>
+ * </tr>
+ * <tr>
+ * <td><code>{@link #getPipeline() pipeline}.removeValve</code></td>
+ * <td><code>Valve</code></td>
+ * <td>Valve removed from this Container.</td>
+ * </tr>
+ * <tr>
+ * <td><code>start</code></td>
+ * <td><code>null</code></td>
+ * <td>Container was started.</td>
+ * </tr>
+ * <tr>
+ * <td><code>stop</code></td>
+ * <td><code>null</code></td>
+ * <td>Container was stopped.</td>
+ * </tr>
  * </table>
- * Subclasses that fire additional events should document them in the
- * class comments of the implementation class.
+ * Subclasses that fire additional events should document them in the class comments of the implementation class.
  *
  * @author Craig R. McClanahan
  */
@@ -131,10 +126,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
     private static final Log log = LogFactory.getLog(ContainerBase.class);
 
     /**
-     * Perform addChild with the permissions of this class.
-     * addChild can be called with the XML parser on the stack,
-     * this allows the XML parser to have fewer privileges than
-     * Tomcat.
+     * Perform addChild with the permissions of this class. addChild can be called with the XML parser on the stack,
+     * this allows the XML parser to have fewer privileges than Tomcat.
      */
     protected class PrivilegedAddChild implements PrivilegedAction<Void> {
 
@@ -169,10 +162,9 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * The container event listeners for this Container. Implemented as a
-     * CopyOnWriteArrayList since listeners may invoke methods to add/remove
-     * themselves or other listeners and with a ReadWriteLock that would trigger
-     * a deadlock.
+     * The container event listeners for this Container. Implemented as a CopyOnWriteArrayList since listeners may
+     * invoke methods to add/remove themselves or other listeners and with a ReadWriteLock that would trigger a
+     * deadlock.
      */
     protected final List<ContainerListener> listeners = new CopyOnWriteArrayList<>();
 
@@ -245,8 +237,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
     /**
      * The property change support for this component.
      */
-    protected final PropertyChangeSupport support =
-            new PropertyChangeSupport(this);
+    protected final PropertyChangeSupport support = new PropertyChangeSupport(this);
 
 
     /**
@@ -262,16 +253,15 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * The access log to use for requests normally handled by this container
-     * that have been handled earlier in the processing chain.
+     * The access log to use for requests normally handled by this container that have been handled earlier in the
+     * processing chain.
      */
     protected volatile AccessLog accessLog = null;
     private volatile boolean accessLogScanComplete = false;
 
 
     /**
-     * The number of threads available to process start and stop events for any
-     * children associated with this container.
+     * The number of threads available to process start and stop events for any children associated with this container.
      */
     private int startStopThreads = 1;
     protected ThreadPoolExecutor startStopExecutor;
@@ -296,7 +286,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
         }
 
         // Zero == Runtime.getRuntime().availableProcessors()
-        // -ve  == Runtime.getRuntime().availableProcessors() + value
+        // -ve == Runtime.getRuntime().availableProcessors() + value
         // These two are the same
         result = Runtime.getRuntime().availableProcessors() + result;
         if (result < 1) {
@@ -320,13 +310,10 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Get the delay between the invocation of the backgroundProcess method on
-     * this container and its children. Child containers will not be invoked
-     * if their delay value is not negative (which would mean they are using
-     * their own thread). Setting this to a positive value will cause
-     * a thread to be spawn. After waiting the specified amount of time,
-     * the thread will invoke the executePeriodic method on this container
-     * and all its children.
+     * Get the delay between the invocation of the backgroundProcess method on this container and its children. Child
+     * containers will not be invoked if their delay value is not negative (which would mean they are using their own
+     * thread). Setting this to a positive value will cause a thread to be spawn. After waiting the specified amount of
+     * time, the thread will invoke the executePeriodic method on this container and all its children.
      */
     @Override
     public int getBackgroundProcessorDelay() {
@@ -335,11 +322,9 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Set the delay between the invocation of the execute method on this
-     * container and its children.
+     * Set the delay between the invocation of the execute method on this container and its children.
      *
-     * @param delay The delay in seconds between the invocation of
-     *              backgroundProcess methods
+     * @param delay The delay in seconds between the invocation of backgroundProcess methods
      */
     @Override
     public void setBackgroundProcessorDelay(int delay) {
@@ -378,8 +363,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             } else if (name.startsWith("##")) {
                 name = "/" + name;
             }
-            loggerName = "[" + name + "]"
-                + ((loggerName != null) ? ("." + loggerName) : "");
+            loggerName = "[" + name + "]" + ((loggerName != null) ? ("." + loggerName) : "");
             current = current.getParent();
         }
         logName = ContainerBase.class.getName() + "." + loggerName;
@@ -389,9 +373,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return the Cluster with which this Container is associated.  If there is
-     * no associated Cluster, return the Cluster associated with our parent
-     * Container (if any); otherwise return <code>null</code>.
+     * Return the Cluster with which this Container is associated. If there is no associated Cluster, return the Cluster
+     * associated with our parent Container (if any); otherwise return <code>null</code>.
      */
     @Override
     public Cluster getCluster() {
@@ -447,8 +430,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             this.cluster = cluster;
 
             // Stop the old component if necessary
-            if (getState().isAvailable() && (oldCluster != null) &&
-                (oldCluster instanceof Lifecycle)) {
+            if (getState().isAvailable() && (oldCluster != null) && (oldCluster instanceof Lifecycle)) {
                 try {
                     ((Lifecycle) oldCluster).stop();
                 } catch (LifecycleException e) {
@@ -461,8 +443,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
                 cluster.setContainer(this);
             }
 
-            if (getState().isAvailable() && (cluster != null) &&
-                (cluster instanceof Lifecycle)) {
+            if (getState().isAvailable() && (cluster != null) && (cluster instanceof Lifecycle)) {
                 try {
                     ((Lifecycle) cluster).start();
                 } catch (LifecycleException e) {
@@ -479,9 +460,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return a name string (suitable for use by humans) that describes this
-     * Container.  Within the set of child containers belonging to a particular
-     * parent, Container names must be unique.
+     * Return a name string (suitable for use by humans) that describes this Container. Within the set of child
+     * containers belonging to a particular parent, Container names must be unique.
      */
     @Override
     public String getName() {
@@ -490,15 +470,13 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Set a name string (suitable for use by humans) that describes this
-     * Container.  Within the set of child containers belonging to a particular
-     * parent, Container names must be unique.
+     * Set a name string (suitable for use by humans) that describes this Container. Within the set of child containers
+     * belonging to a particular parent, Container names must be unique.
      *
      * @param name New name of this container
      *
-     * @exception IllegalStateException if this Container has already been
-     *  added to the children of a parent Container (after which the name
-     *  may not be changed)
+     * @exception IllegalStateException if this Container has already been added to the children of a parent Container
+     *                                      (after which the name may not be changed)
      */
     @Override
     public void setName(String name) {
@@ -512,8 +490,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return if children of this container will be started automatically when
-     * they are added to this container.
+     * Return if children of this container will be started automatically when they are added to this container.
      *
      * @return <code>true</code> if the children will be started
      */
@@ -523,8 +500,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Set if children of this container will be started automatically when
-     * they are added to this container.
+     * Set if children of this container will be started automatically when they are added to this container.
      *
      * @param startChildren New value of the startChildren flag
      */
@@ -537,8 +513,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return the Container for which this Container is a child, if there is
-     * one.  If there is no defined parent, return <code>null</code>.
+     * Return the Container for which this Container is a child, if there is one. If there is no defined parent, return
+     * <code>null</code>.
      */
     @Override
     public Container getParent() {
@@ -547,15 +523,12 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Set the parent Container to which this Container is being added as a
-     * child.  This Container may refuse to become attached to the specified
-     * Container by throwing an exception.
+     * Set the parent Container to which this Container is being added as a child. This Container may refuse to become
+     * attached to the specified Container by throwing an exception.
      *
-     * @param container Container to which this Container is being added
-     *  as a child
+     * @param container Container to which this Container is being added as a child
      *
-     * @exception IllegalArgumentException if this Container refuses to become
-     *  attached to the specified Container
+     * @exception IllegalArgumentException if this Container refuses to become attached to the specified Container
      */
     @Override
     public void setParent(Container container) {
@@ -568,9 +541,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return the parent class loader (if any) for this web application.
-     * This call is meaningful only <strong>after</strong> a Loader has
-     * been configured.
+     * Return the parent class loader (if any) for this web application. This call is meaningful only
+     * <strong>after</strong> a Loader has been configured.
      */
     @Override
     public ClassLoader getParentClassLoader() {
@@ -585,11 +557,9 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Set the parent class loader (if any) for this web application.
-     * This call is meaningful only <strong>before</strong> a Loader has
-     * been configured, and the specified value (if non-null) should be
-     * passed as an argument to the class loader constructor.
-     *
+     * Set the parent class loader (if any) for this web application. This call is meaningful only
+     * <strong>before</strong> a Loader has been configured, and the specified value (if non-null) should be passed as
+     * an argument to the class loader constructor.
      *
      * @param parent The new parent class loader
      */
@@ -597,15 +567,13 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
     public void setParentClassLoader(ClassLoader parent) {
         ClassLoader oldParentClassLoader = this.parentClassLoader;
         this.parentClassLoader = parent;
-        support.firePropertyChange("parentClassLoader", oldParentClassLoader,
-                                   this.parentClassLoader);
+        support.firePropertyChange("parentClassLoader", oldParentClassLoader, this.parentClassLoader);
 
     }
 
 
     /**
-     * Return the Pipeline object that manages the Valves associated with
-     * this Container.
+     * Return the Pipeline object that manages the Valves associated with this Container.
      */
     @Override
     public Pipeline getPipeline() {
@@ -614,9 +582,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return the Realm with which this Container is associated.  If there is
-     * no associated Realm, return the Realm associated with our parent
-     * Container (if any); otherwise return <code>null</code>.
+     * Return the Realm with which this Container is associated. If there is no associated Realm, return the Realm
+     * associated with our parent Container (if any); otherwise return <code>null</code>.
      */
     @Override
     public Realm getRealm() {
@@ -666,8 +633,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             this.realm = realm;
 
             // Stop the old component if necessary
-            if (getState().isAvailable() && (oldRealm != null) &&
-                (oldRealm instanceof Lifecycle)) {
+            if (getState().isAvailable() && (oldRealm != null) && (oldRealm instanceof Lifecycle)) {
                 try {
                     ((Lifecycle) oldRealm).stop();
                 } catch (LifecycleException e) {
@@ -679,8 +645,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             if (realm != null) {
                 realm.setContainer(this);
             }
-            if (getState().isAvailable() && (realm != null) &&
-                (realm instanceof Lifecycle)) {
+            if (getState().isAvailable() && (realm != null) && (realm instanceof Lifecycle)) {
                 try {
                     ((Lifecycle) realm).start();
                 } catch (LifecycleException e) {
@@ -701,27 +666,23 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Add a new child Container to those associated with this Container,
-     * if supported.  Prior to adding this Container to the set of children,
-     * the child's <code>setParent()</code> method must be called, with this
-     * Container as an argument.  This method may thrown an
-     * <code>IllegalArgumentException</code> if this Container chooses not
-     * to be attached to the specified Container, in which case it is not added
+     * Add a new child Container to those associated with this Container, if supported. Prior to adding this Container
+     * to the set of children, the child's <code>setParent()</code> method must be called, with this Container as an
+     * argument. This method may thrown an <code>IllegalArgumentException</code> if this Container chooses not to be
+     * attached to the specified Container, in which case it is not added
      *
      * @param child New child Container to be added
      *
-     * @exception IllegalArgumentException if this exception is thrown by
-     *  the <code>setParent()</code> method of the child Container
-     * @exception IllegalArgumentException if the new child does not have
-     *  a name unique from that of existing children of this Container
-     * @exception IllegalStateException if this Container does not support
-     *  child Containers
+     * @exception IllegalArgumentException if this exception is thrown by the <code>setParent()</code> method of the
+     *                                         child Container
+     * @exception IllegalArgumentException if the new child does not have a name unique from that of existing children
+     *                                         of this Container
+     * @exception IllegalStateException    if this Container does not support child Containers
      */
     @Override
     public void addChild(Container child) {
         if (Globals.IS_SECURITY_ENABLED) {
-            PrivilegedAction<Void> dp =
-                new PrivilegedAddChild(child);
+            PrivilegedAction<Void> dp = new PrivilegedAddChild(child);
             AccessController.doPrivileged(dp);
         } else {
             addChildInternal(child);
@@ -734,12 +695,11 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             log.debug("Add child " + child + " " + this);
         }
 
-        synchronized(children) {
+        synchronized (children) {
             if (children.get(child.getName()) != null) {
-                throw new IllegalArgumentException(
-                        sm.getString("containerBase.child.notUnique", child.getName()));
+                throw new IllegalArgumentException(sm.getString("containerBase.child.notUnique", child.getName()));
             }
-            child.setParent(this);  // May throw IAE
+            child.setParent(this); // May throw IAE
             children.put(child.getName(), child);
         }
 
@@ -747,9 +707,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
         // Don't do this inside sync block - start can be a slow process and
         // locking the children object can cause problems elsewhere
         try {
-            if ((getState().isAvailable() ||
-                    LifecycleState.STARTING_PREP.equals(getState())) &&
-                    startChildren) {
+            if ((getState().isAvailable() || LifecycleState.STARTING_PREP.equals(getState())) && startChildren) {
                 child.start();
             }
         } catch (LifecycleException e) {
@@ -784,8 +742,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return the child Container, associated with this Container, with
-     * the specified name (if any); otherwise, return <code>null</code>
+     * Return the child Container, associated with this Container, with the specified name (if any); otherwise, return
+     * <code>null</code>
      *
      * @param name Name of the child Container to be retrieved
      */
@@ -801,8 +759,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return the set of children Containers associated with this Container.
-     * If this Container has no children, a zero-length array is returned.
+     * Return the set of children Containers associated with this Container. If this Container has no children, a
+     * zero-length array is returned.
      */
     @Override
     public Container[] findChildren() {
@@ -813,9 +771,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Return the set of container listeners associated with this Container.
-     * If this Container has no registered container listeners, a zero-length
-     * array is returned.
+     * Return the set of container listeners associated with this Container. If this Container has no registered
+     * container listeners, a zero-length array is returned.
      */
     @Override
     public ContainerListener[] findContainerListeners() {
@@ -824,8 +781,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Remove an existing child Container from association with this parent
-     * Container.
+     * Remove an existing child Container from association with this parent Container.
      *
      * @param child Existing child Container to be removed
      */
@@ -855,7 +811,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             log.error(sm.getString("containerBase.child.destroy"), e);
         }
 
-        synchronized(children) {
+        synchronized (children) {
             if (children.get(child.getName()) == null) {
                 return;
             }
@@ -893,22 +849,19 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
     @Override
     protected void initInternal() throws LifecycleException {
         BlockingQueue<Runnable> startStopQueue = new LinkedBlockingQueue<>();
-        startStopExecutor = new ThreadPoolExecutor(
-                getStartStopThreadsInternal(),
-                getStartStopThreadsInternal(), 10, TimeUnit.SECONDS,
-                startStopQueue,
-                new StartStopThreadFactory(getName() + "-startStop-"));
+        startStopExecutor = new ThreadPoolExecutor(getStartStopThreadsInternal(), getStartStopThreadsInternal(), 10,
+                TimeUnit.SECONDS, startStopQueue, new StartStopThreadFactory(getName() + "-startStop-"));
         startStopExecutor.allowCoreThreadTimeOut(true);
         super.initInternal();
     }
 
 
     /**
-     * Start this component and implement the requirements
-     * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
+     * Start this component and implement the requirements of
+     * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
      *
-     * @exception LifecycleException if this component detects a fatal error
-     *  that prevents this component from being used
+     * @exception LifecycleException if this component detects a fatal error that prevents this component from being
+     *                                   used
      */
     @Override
     protected synchronized void startInternal() throws LifecycleException {
@@ -964,11 +917,11 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Stop this component and implement the requirements
-     * of {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
+     * Stop this component and implement the requirements of
+     * {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
      *
-     * @exception LifecycleException if this component detects a fatal error
-     *  that prevents this component from being used
+     * @exception LifecycleException if this component detects a fatal error that prevents this component from being
+     *                                   used
      */
     @Override
     protected synchronized void stopInternal() throws LifecycleException {
@@ -979,8 +932,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
         setState(LifecycleState.STOPPING);
 
         // Stop the Valves in our pipeline (including the basic), if any
-        if (pipeline instanceof Lifecycle &&
-                ((Lifecycle) pipeline).getState().isAvailable()) {
+        if (pipeline instanceof Lifecycle && ((Lifecycle) pipeline).getState().isAvailable()) {
             ((Lifecycle) pipeline).stop();
         }
 
@@ -1001,8 +953,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             }
         }
         if (fail) {
-            throw new LifecycleException(
-                    sm.getString("containerBase.threadedStopFailed"));
+            throw new LifecycleException(sm.getString("containerBase.threadedStopFailed"));
         }
 
         // Stop our subordinate components, if any
@@ -1053,13 +1004,11 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Check this container for an access log and if none is found, look to the
-     * parent. If there is no parent and still none is found, use the NoOp
-     * access log.
+     * Check this container for an access log and if none is found, look to the parent. If there is no parent and still
+     * none is found, use the NoOp access log.
      */
     @Override
-    public void logAccess(Request request, Response response, long time,
-            boolean useDefault) {
+    public void logAccess(Request request, Response response, long time, boolean useDefault) {
 
         boolean logged = false;
 
@@ -1104,21 +1053,16 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Convenience method, intended for use by the digester to simplify the
-     * process of adding Valves to containers. See
-     * {@link Pipeline#addValve(Valve)} for full details. Components other than
-     * the digester should use {@link #getPipeline()}.{@link #addValve(Valve)} in case a
-     * future implementation provides an alternative method for the digester to
-     * use.
+     * Convenience method, intended for use by the digester to simplify the process of adding Valves to containers. See
+     * {@link Pipeline#addValve(Valve)} for full details. Components other than the digester should use
+     * {@link #getPipeline()}.{@link #addValve(Valve)} in case a future implementation provides an alternative method
+     * for the digester to use.
      *
      * @param valve Valve to be added
      *
-     * @exception IllegalArgumentException if this Container refused to
-     *  accept the specified Valve
-     * @exception IllegalArgumentException if the specified Valve refuses to be
-     *  associated with this Container
-     * @exception IllegalStateException if the specified Valve is already
-     *  associated with a different Container
+     * @exception IllegalArgumentException if this Container refused to accept the specified Valve
+     * @exception IllegalArgumentException if the specified Valve refuses to be associated with this Container
+     * @exception IllegalStateException    if the specified Valve is already associated with a different Container
      */
     public synchronized void addValve(Valve valve) {
 
@@ -1127,9 +1071,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Execute a periodic task, such as reloading, etc. This method will be
-     * invoked inside the classloading context of this container. Unexpected
-     * throwables will be caught and logged.
+     * Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of
+     * this container. Unexpected throwables will be caught and logged.
      */
     @Override
     public void backgroundProcess() {
@@ -1143,8 +1086,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             try {
                 cluster.backgroundProcess();
             } catch (Exception e) {
-                log.warn(sm.getString("containerBase.backgroundProcess.cluster",
-                        cluster), e);
+                log.warn(sm.getString("containerBase.backgroundProcess.cluster", cluster), e);
             }
         }
         Realm realm = getRealmInternal();
@@ -1193,9 +1135,8 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
     // ------------------------------------------------------ Protected Methods
 
     /**
-     * Notify all container event listeners that a particular event has
-     * occurred for this Container.  The default implementation performs
-     * this notification synchronously using the calling thread.
+     * Notify all container event listeners that a particular event has occurred for this Container. The default
+     * implementation performs this notification synchronously using the calling thread.
      *
      * @param type Event type
      * @param data Event data
@@ -1215,7 +1156,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
     }
 
 
-    // -------------------- JMX and Registration  --------------------
+    // -------------------- JMX and Registration --------------------
 
     @Override
     protected String getDomainInternal() {
@@ -1244,7 +1185,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
             } else if (c instanceof Context) {
                 keyProperties.insert(0, ",context=");
                 ContextName cn = new ContextName(c.getName(), false);
-                keyProperties.insert(9,cn.getDisplayName());
+                keyProperties.insert(9, cn.getDisplayName());
             } else if (c instanceof Host) {
                 keyProperties.insert(0, ",host=");
                 keyProperties.insert(6, c.getName());
@@ -1270,7 +1211,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
         List<ObjectName> names = new ArrayList<>(children.size());
         for (Container next : children.values()) {
             if (next instanceof ContainerBase) {
-                names.add(((ContainerBase)next).getObjectName());
+                names.add(((ContainerBase) next).getObjectName());
             }
         }
         return names.toArray(new ObjectName[0]);
@@ -1280,8 +1221,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
     // -------------------- Background Thread --------------------
 
     /**
-     * Start the background thread that will periodically check for
-     * session timeouts.
+     * Start the background thread that will periodically check for session timeouts.
      */
     protected void threadStart() {
 
@@ -1302,8 +1242,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
 
 
     /**
-     * Stop the background thread that is periodically checking for
-     * session timeouts.
+     * Stop the background thread that is periodically checking for session timeouts.
      */
     protected void threadStop() {
 
@@ -1343,16 +1282,15 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
     // -------------------------------------- ContainerExecuteDelay Inner Class
 
     /**
-     * Private runnable class to invoke the backgroundProcess method
-     * of this container and its children after a fixed delay.
+     * Private runnable class to invoke the backgroundProcess method of this container and its children after a fixed
+     * delay.
      */
     protected class ContainerBackgroundProcessor implements Runnable {
 
         @Override
         public void run() {
             Throwable t = null;
-            String unexpectedDeathMessage = sm.getString(
-                    "containerBase.backgroundProcess.unexpectedThreadDeath",
+            String unexpectedDeathMessage = sm.getString("containerBase.backgroundProcess.unexpectedThreadDeath",
                     Thread.currentThread().getName());
             try {
                 while (!threadDone) {
@@ -1365,7 +1303,7 @@ public abstract class ContainerBase extends LifecycleMBeanBase implements Contai
                         processChildren(ContainerBase.this);
                     }
                 }
-            } catch (RuntimeException|Error e) {
+            } catch (RuntimeException | Error e) {
                 t = e;
                 throw e;
             } finally {
diff --git a/java/org/apache/catalina/core/DefaultInstanceManager.java b/java/org/apache/catalina/core/DefaultInstanceManager.java
index c0c17829b2..039f5a0403 100644
--- a/java/org/apache/catalina/core/DefaultInstanceManager.java
+++ b/java/org/apache/catalina/core/DefaultInstanceManager.java
@@ -58,8 +58,7 @@ import org.apache.tomcat.util.res.StringManager;
 public class DefaultInstanceManager implements InstanceManager {
 
     // Used when there are no annotations in a class
-    private static final AnnotationCacheEntry[] ANNOTATIONS_EMPTY
-        = new AnnotationCacheEntry[0];
+    private static final AnnotationCacheEntry[] ANNOTATIONS_EMPTY = new AnnotationCacheEntry[0];
 
     /**
      * The string manager for this package.
@@ -104,29 +103,23 @@ public class DefaultInstanceManager implements InstanceManager {
     protected final boolean privileged;
     protected final boolean ignoreAnnotations;
     private final Set<String> restrictedClasses;
-    private final ManagedConcurrentWeakHashMap<Class<?>, AnnotationCacheEntry[]> annotationCache =
-            new ManagedConcurrentWeakHashMap<>();
+    private final ManagedConcurrentWeakHashMap<Class<?>, AnnotationCacheEntry[]> annotationCache = new ManagedConcurrentWeakHashMap<>();
     private final Map<String, String> postConstructMethods;
     private final Map<String, String> preDestroyMethods;
 
-    public DefaultInstanceManager(Context context,
-            Map<String, Map<String, String>> injectionMap,
-            org.apache.catalina.Context catalinaContext,
-            ClassLoader containerClassLoader) {
+    public DefaultInstanceManager(Context context, Map<String, Map<String, String>> injectionMap,
+            org.apache.catalina.Context catalinaContext, ClassLoader containerClassLoader) {
         classLoader = catalinaContext.getLoader().getClassLoader();
         privileged = catalinaContext.getPrivileged();
         this.containerClassLoader = containerClassLoader;
         ignoreAnnotations = catalinaContext.getIgnoreAnnotations();
         Log log = catalinaContext.getLogger();
         Set<String> classNames = new HashSet<>();
-        loadProperties(classNames,
-                "org/apache/catalina/core/RestrictedServlets.properties",
+        loadProperties(classNames, "org/apache/catalina/core/RestrictedServlets.properties",
                 "defaultInstanceManager.restrictedServletsResource", log);
-        loadProperties(classNames,
-                "org/apache/catalina/core/RestrictedListeners.properties",
+        loadProperties(classNames, "org/apache/catalina/core/RestrictedListeners.properties",
                 "defaultInstanceManager.restrictedListenersResource", log);
-        loadProperties(classNames,
-                "org/apache/catalina/core/RestrictedFilters.properties",
+        loadProperties(classNames, "org/apache/catalina/core/RestrictedFilters.properties",
                 "defaultInstanceManager.restrictedFiltersResource", log);
         restrictedClasses = Collections.unmodifiableSet(classNames);
         this.context = context;
@@ -136,15 +129,14 @@ public class DefaultInstanceManager implements InstanceManager {
     }
 
     @Override
-    public Object newInstance(Class<?> clazz) throws IllegalAccessException,
-            InvocationTargetException, NamingException, InstantiationException,
-            IllegalArgumentException, NoSuchMethodException, SecurityException {
+    public Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException,
+            InstantiationException, IllegalArgumentException, NoSuchMethodException, SecurityException {
         return newInstance(clazz.getConstructor().newInstance(), clazz);
     }
 
     @Override
-    public Object newInstance(String className) throws IllegalAccessException,
-            InvocationTargetException, NamingException, InstantiationException,
+    public Object newInstance(String className)
+            throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException,
             ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException {
         Class<?> clazz = loadClassMaybePrivileged(className, classLoader);
         return newInstance(clazz.getConstructor().newInstance(), clazz);
@@ -152,16 +144,14 @@ public class DefaultInstanceManager implements InstanceManager {
 
     @Override
     public Object newInstance(final String className, final ClassLoader classLoader)
-            throws IllegalAccessException, NamingException, InvocationTargetException,
-            InstantiationException, ClassNotFoundException, IllegalArgumentException,
-            NoSuchMethodException, SecurityException {
+            throws IllegalAccessException, NamingException, InvocationTargetException, InstantiationException,
+            ClassNotFoundException, IllegalArgumentException, NoSuchMethodException, SecurityException {
         Class<?> clazz = classLoader.loadClass(className);
         return newInstance(clazz.getConstructor().newInstance(), clazz);
     }
 
     @Override
-    public void newInstance(Object o)
-            throws IllegalAccessException, InvocationTargetException, NamingException {
+    public void newInstance(Object o) throws IllegalAccessException, InvocationTargetException, NamingException {
         newInstance(o, o.getClass());
     }
 
@@ -190,22 +180,20 @@ public class DefaultInstanceManager implements InstanceManager {
     }
 
     @Override
-    public void destroyInstance(Object instance) throws IllegalAccessException,
-            InvocationTargetException {
+    public void destroyInstance(Object instance) throws IllegalAccessException, InvocationTargetException {
         if (!ignoreAnnotations) {
             preDestroy(instance, instance.getClass());
         }
     }
 
     /**
-     * Call postConstruct method on the specified instance recursively from
-     * deepest superclass to actual class.
+     * Call postConstruct method on the specified instance recursively from deepest superclass to actual class.
      *
      * @param instance object to call postconstruct methods on
      * @param clazz    (super) class to examine for postConstruct annotation.
-     * @throws IllegalAccessException if postConstruct method is inaccessible.
-     * @throws java.lang.reflect.InvocationTargetException
-     *                                if call fails
+     *
+     * @throws IllegalAccessException                      if postConstruct method is inaccessible.
+     * @throws java.lang.reflect.InvocationTargetException if call fails
      */
     protected void postConstruct(Object instance, final Class<?> clazz)
             throws IllegalAccessException, InvocationTargetException {
@@ -235,14 +223,13 @@ public class DefaultInstanceManager implements InstanceManager {
 
 
     /**
-     * Call preDestroy method on the specified instance recursively from deepest
-     * superclass to actual class.
+     * Call preDestroy method on the specified instance recursively from deepest superclass to actual class.
      *
      * @param instance object to call preDestroy methods on
      * @param clazz    (super) class to examine for preDestroy annotation.
-     * @throws IllegalAccessException if preDestroy method is inaccessible.
-     * @throws java.lang.reflect.InvocationTargetException
-     *                                if call fails
+     *
+     * @throws IllegalAccessException                      if preDestroy method is inaccessible.
+     * @throws java.lang.reflect.InvocationTargetException if call fails
      */
     protected void preDestroy(Object instance, final Class<?> clazz)
             throws IllegalAccessException, InvocationTargetException {
@@ -276,20 +263,17 @@ public class DefaultInstanceManager implements InstanceManager {
 
 
     /**
-     * Make sure that the annotations cache has been populated for the provided
-     * class.
+     * Make sure that the annotations cache has been populated for the provided class.
+     *
+     * @param clazz      clazz to populate annotations for
+     * @param injections map of injections for this class from xml deployment descriptor
      *
-     * @param clazz         clazz to populate annotations for
-     * @param injections    map of injections for this class from xml deployment
-     *                      descriptor
-     * @throws IllegalAccessException       if injection target is inaccessible
-     * @throws javax.naming.NamingException if value cannot be looked up in jndi
-     * @throws java.lang.reflect.InvocationTargetException
-     *                                      if injection fails
+     * @throws IllegalAccessException                      if injection target is inaccessible
+     * @throws javax.naming.NamingException                if value cannot be looked up in jndi
+     * @throws java.lang.reflect.InvocationTargetException if injection fails
      */
-    protected void populateAnnotationsCache(Class<?> clazz,
-            Map<String, String> injections) throws IllegalAccessException,
-            InvocationTargetException, NamingException {
+    protected void populateAnnotationsCache(Class<?> clazz, Map<String, String> injections)
+            throws IllegalAccessException, InvocationTargetException, NamingException {
 
         List<AnnotationCacheEntry> annotations = null;
         Set<String> injectionsMatchedToSetter = new HashSet<>();
@@ -316,11 +300,8 @@ public class DefaultInstanceManager implements InstanceManager {
                             String fieldName = Introspection.getPropertyName(method);
                             injectionsMatchedToSetter.add(fieldName);
                             if (injections.containsKey(fieldName)) {
-                                annotations.add(new AnnotationCacheEntry(
-                                        method.getName(),
-                                        method.getParameterTypes(),
-                                        injections.get(fieldName),
-                                        AnnotationCacheEntryType.SETTER));
+                                annotations.add(new AnnotationCacheEntry(method.getName(), method.getParameterTypes(),
+                                        injections.get(fieldName), AnnotationCacheEntryType.SETTER));
                                 continue;
                             }
                         }
@@ -330,37 +311,23 @@ public class DefaultInstanceManager implements InstanceManager {
                         Annotation persistenceContextAnnotation;
                         Annotation persistenceUnitAnnotation;
                         if ((resourceAnnotation = method.getAnnotation(Resource.class)) != null) {
-                            annotations.add(new AnnotationCacheEntry(
-                                    method.getName(),
-                                    method.getParameterTypes(),
-                                    resourceAnnotation.name(),
-                                    AnnotationCacheEntryType.SETTER));
-                        } else if (EJB_PRESENT &&
-                                (ejbAnnotation = method.getAnnotation(EJB.class)) != null) {
-                            annotations.add(new AnnotationCacheEntry(
-                                    method.getName(),
-                                    method.getParameterTypes(),
-                                    ((EJB) ejbAnnotation).name(),
-                                    AnnotationCacheEntryType.SETTER));
-                        } else if (WS_PRESENT && (webServiceRefAnnotation =
-                                method.getAnnotation(WebServiceRef.class)) != null) {
-                            annotations.add(new AnnotationCacheEntry(
-                                    method.getName(),
-                                    method.getParameterTypes(),
-                                    ((WebServiceRef) webServiceRefAnnotation).name(),
-                                    AnnotationCacheEntryType.SETTER));
-                        } else if (JPA_PRESENT && (persistenceContextAnnotation =
-                                method.getAnnotation(PersistenceContext.class)) != null) {
-                            annotations.add(new AnnotationCacheEntry(
-                                    method.getName(),
-                                    method.getParameterTypes(),
+                            annotations.add(new AnnotationCacheEntry(method.getName(), method.getParameterTypes(),
+                                    resourceAnnotation.name(), AnnotationCacheEntryType.SETTER));
+                        } else if (EJB_PRESENT && (ejbAnnotation = method.getAnnotation(EJB.class)) != null) {
+                            annotations.add(new AnnotationCacheEntry(method.getName(), method.getParameterTypes(),
+                                    ((EJB) ejbAnnotation).name(), AnnotationCacheEntryType.SETTER));
+                        } else if (WS_PRESENT &&
+                                (webServiceRefAnnotation = method.getAnnotation(WebServiceRef.class)) != null) {
+                            annotations.add(new AnnotationCacheEntry(method.getName(), method.getParameterTypes(),
+                                    ((WebServiceRef) webServiceRefAnnotation).name(), AnnotationCacheEntryType.SETTER));
+                        } else if (JPA_PRESENT && (persistenceContextAnnotation = method
+                                .getAnnotation(PersistenceContext.class)) != null) {
+                            annotations.add(new AnnotationCacheEntry(method.getName(), method.getParameterTypes(),
                                     ((PersistenceContext) persistenceContextAnnotation).name(),
                                     AnnotationCacheEntryType.SETTER));
-                        } else if (JPA_PRESENT && (persistenceUnitAnnotation =
-                                method.getAnnotation(PersistenceUnit.class)) != null) {
-                            annotations.add(new AnnotationCacheEntry(
-                                    method.getName(),
-                                    method.getParameterTypes(),
+                        } else if (JPA_PRESENT &&
+                                (persistenceUnitAnnotation = method.getAnnotation(PersistenceUnit.class)) != null) {
+                            annotations.add(new AnnotationCacheEntry(method.getName(), method.getParameterTypes(),
                                     ((PersistenceUnit) persistenceUnitAnnotation).name(),
                                     AnnotationCacheEntryType.SETTER));
                         }
@@ -372,22 +339,18 @@ public class DefaultInstanceManager implements InstanceManager {
                 }
 
                 if (postConstruct != null) {
-                    annotations.add(new AnnotationCacheEntry(
-                            postConstruct.getName(),
-                            postConstruct.getParameterTypes(), null,
-                            AnnotationCacheEntryType.POST_CONSTRUCT));
+                    annotations.add(new AnnotationCacheEntry(postConstruct.getName(), postConstruct.getParameterTypes(),
+                            null, AnnotationCacheEntryType.POST_CONSTRUCT));
                 } else if (postConstructFromXml != null) {
                     throw new IllegalArgumentException(sm.getString("defaultInstanceManager.postConstructNotFound",
-                        postConstructFromXml, clazz.getName()));
+                            postConstructFromXml, clazz.getName()));
                 }
                 if (preDestroy != null) {
-                    annotations.add(new AnnotationCacheEntry(
-                            preDestroy.getName(),
-                            preDestroy.getParameterTypes(), null,
+                    annotations.add(new AnnotationCacheEntry(preDestroy.getName(), preDestroy.getParameterTypes(), null,
                             AnnotationCacheEntryType.PRE_DESTROY));
                 } else if (preDestroyFromXml != null) {
                     throw new IllegalArgumentException(sm.getString("defaultInstanceManager.preDestroyNotFound",
-                        preDestroyFromXml, clazz.getName()));
+                            preDestroyFromXml, clazz.getName()));
                 }
 
                 if (context != null) {
@@ -401,31 +364,27 @@ public class DefaultInstanceManager implements InstanceManager {
                         Annotation persistenceContextAnnotation;
                         Annotation persistenceUnitAnnotation;
                         String fieldName = field.getName();
-                        if (injections != null && injections.containsKey(fieldName) && !injectionsMatchedToSetter.contains(fieldName)) {
-                            annotations.add(new AnnotationCacheEntry(
-                                    fieldName, null,
-                                    injections.get(fieldName),
+                        if (injections != null && injections.containsKey(fieldName) &&
+                                !injectionsMatchedToSetter.contains(fieldName)) {
+                            annotations.add(new AnnotationCacheEntry(fieldName, null, injections.get(fieldName),
                                     AnnotationCacheEntryType.FIELD));
-                        } else if ((resourceAnnotation =
-                                field.getAnnotation(Resource.class)) != null) {
-                            annotations.add(new AnnotationCacheEntry(fieldName, null,
-                                    resourceAnnotation.name(), AnnotationCacheEntryType.FIELD));
-                        } else if (EJB_PRESENT &&
-                                (ejbAnnotation = field.getAnnotation(EJB.class)) != null) {
-                            annotations.add(new AnnotationCacheEntry(fieldName, null,
-                                    ((EJB) ejbAnnotation).name(), AnnotationCacheEntryType.FIELD));
-                        } else if (WS_PRESENT && (webServiceRefAnnotation =
-                                field.getAnnotation(WebServiceRef.class)) != null) {
-                            annotations.add(new AnnotationCacheEntry(fieldName, null,
-                                    ((WebServiceRef) webServiceRefAnnotation).name(),
+                        } else if ((resourceAnnotation = field.getAnnotation(Resource.class)) != null) {
+                            annotations.add(new AnnotationCacheEntry(fieldName, null, resourceAnnotation.name(),
+                                    AnnotationCacheEntryType.FIELD));
+                        } else if (EJB_PRESENT && (ejbAnnotation = field.getAnnotation(EJB.class)) != null) {
+                            annotations.add(new AnnotationCacheEntry(fieldName, null, ((EJB) ejbAnnotation).name(),
                                     AnnotationCacheEntryType.FIELD));
-                        } else if (JPA_PRESENT && (persistenceContextAnnotation =
-                                field.getAnnotation(PersistenceContext.class)) != null) {
+                        } else if (WS_PRESENT &&
+                                (webServiceRefAnnotation = field.getAnnotation(WebServiceRef.class)) != null) {
+                            annotations.add(new AnnotationCacheEntry(fieldName, null,
+                                    ((WebServiceRef) webServiceRefAnnotation).name(), AnnotationCacheEntryType.FIELD));
+                        } else if (JPA_PRESENT && (persistenceContextAnnotation = field
+                                .getAnnotation(PersistenceContext.class)) != null) {
                             annotations.add(new AnnotationCacheEntry(fieldName, null,
                                     ((PersistenceContext) persistenceContextAnnotation).name(),
                                     AnnotationCacheEntryType.FIELD));
-                        } else if (JPA_PRESENT && (persistenceUnitAnnotation =
-                                field.getAnnotation(PersistenceUnit.class)) != null) {
+                        } else if (JPA_PRESENT &&
+                                (persistenceUnitAnnotation = field.getAnnotation(PersistenceUnit.class)) != null) {
                             annotations.add(new AnnotationCacheEntry(fieldName, null,
                                     ((PersistenceUnit) persistenceUnitAnnotation).name(),
                                     AnnotationCacheEntryType.FIELD));
@@ -453,10 +412,10 @@ public class DefaultInstanceManager implements InstanceManager {
      *
      * @param instance   instance to inject into
      * @param injections map of injections for this class from xml deployment descriptor
-     * @throws IllegalAccessException       if injection target is inaccessible
-     * @throws javax.naming.NamingException if value cannot be looked up in jndi
-     * @throws java.lang.reflect.InvocationTargetException
-     *                                      if injection fails
+     *
+     * @throws IllegalAccessException                      if injection target is inaccessible
+     * @throws javax.naming.NamingException                if value cannot be looked up in jndi
+     * @throws java.lang.reflect.InvocationTargetException if injection fails
      */
     protected void processAnnotations(Object instance, Map<String, String> injections)
             throws IllegalAccessException, InvocationTargetException, NamingException {
@@ -472,13 +431,9 @@ public class DefaultInstanceManager implements InstanceManager {
             AnnotationCacheEntry[] annotations = annotationCache.get(clazz);
             for (AnnotationCacheEntry entry : annotations) {
                 if (entry.getType() == AnnotationCacheEntryType.SETTER) {
-                    lookupMethodResource(context, instance,
-                            getMethod(clazz, entry),
-                            entry.getName(), clazz);
+                    lookupMethodResource(context, instance, getMethod(clazz, entry), entry.getName(), clazz);
                 } else if (entry.getType() == AnnotationCacheEntryType.FIELD) {
-                    lookupFieldResource(context, instance,
-                            getField(clazz, entry),
-                            entry.getName(), clazz);
+                    lookupFieldResource(context, instance, getField(clazz, entry), entry.getName(), clazz);
                 }
             }
             clazz = clazz.getSuperclass();
@@ -496,13 +451,12 @@ public class DefaultInstanceManager implements InstanceManager {
     }
 
 
-    protected Class<?> loadClassMaybePrivileged(final String className,
-            final ClassLoader classLoader) throws ClassNotFoundException {
+    protected Class<?> loadClassMaybePrivileged(final String className, final ClassLoader classLoader)
+            throws ClassNotFoundException {
         Class<?> clazz;
         if (SecurityUtil.isPackageProtectionEnabled()) {
             try {
-                clazz = AccessController.doPrivileged(
-                        new PrivilegedLoadClass(className, classLoader));
+                clazz = AccessController.doPrivileged(new PrivilegedLoadClass(className, classLoader));
             } catch (PrivilegedActionException e) {
                 Throwable t = e.getCause();
                 if (t instanceof ClassNotFoundException) {
@@ -517,8 +471,7 @@ public class DefaultInstanceManager implements InstanceManager {
         return clazz;
     }
 
-    protected Class<?> loadClass(String className, ClassLoader classLoader)
-            throws ClassNotFoundException {
+    protected Class<?> loadClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
         if (className.startsWith("org.apache.catalina")) {
             return containerClassLoader.loadClass(className);
         }
@@ -538,13 +491,11 @@ public class DefaultInstanceManager implements InstanceManager {
             return;
         }
         if (ContainerServlet.class.isAssignableFrom(clazz)) {
-            throw new SecurityException(sm.getString(
-                    "defaultInstanceManager.restrictedContainerServlet", clazz));
+            throw new SecurityException(sm.getString("defaultInstanceManager.restrictedContainerServlet", clazz));
         }
         while (clazz != null) {
             if (restrictedClasses.contains(clazz.getName())) {
-                throw new SecurityException(sm.getString(
-                        "defaultInstanceManager.restrictedClass", clazz));
+                throw new SecurityException(sm.getString("defaultInstanceManager.restrictedClass", clazz));
             }
             clazz = clazz.getSuperclass();
         }
@@ -558,12 +509,12 @@ public class DefaultInstanceManager implements InstanceManager {
      * @param field    field target for injection
      * @param name     jndi name value is bound under
      * @param clazz    class annotation is defined in
+     *
      * @throws IllegalAccessException       if field is inaccessible
      * @throws javax.naming.NamingException if value is not accessible in naming context
      */
-    protected static void lookupFieldResource(Context context,
-            Object instance, Field field, String name, Class<?> clazz)
-            throws NamingException, IllegalAccessException {
+    protected static void lookupFieldResource(Context context, Object instance, Field field, String name,
+            Class<?> clazz) throws NamingException, IllegalAccessException {
 
         Object lookedupResource;
 
@@ -572,8 +523,7 @@ public class DefaultInstanceManager implements InstanceManager {
         if ((normalizedName != null) && (normalizedName.length() > 0)) {
             lookedupResource = context.lookup(normalizedName);
         } else {
-            lookedupResource =
-                context.lookup(clazz.getName() + "/" + field.getName());
+            lookedupResource = context.lookup(clazz.getName() + "/" + field.getName());
         }
 
         // This will always be a new Field instance
@@ -590,18 +540,16 @@ public class DefaultInstanceManager implements InstanceManager {
      * @param method   field target for injection
      * @param name     jndi name value is bound under
      * @param clazz    class annotation is defined in
-     * @throws IllegalAccessException       if method is inaccessible
-     * @throws javax.naming.NamingException if value is not accessible in naming context
-     * @throws java.lang.reflect.InvocationTargetException
-     *                                      if setter call fails
+     *
+     * @throws IllegalAccessException                      if method is inaccessible
+     * @throws javax.naming.NamingException                if value is not accessible in naming context
+     * @throws java.lang.reflect.InvocationTargetException if setter call fails
      */
-    protected static void lookupMethodResource(Context context,
-            Object instance, Method method, String name, Class<?> clazz)
-            throws NamingException, IllegalAccessException, InvocationTargetException {
+    protected static void lookupMethodResource(Context context, Object instance, Method method, String name,
+            Class<?> clazz) throws NamingException, IllegalAccessException, InvocationTargetException {
 
         if (!Introspection.isValidSetter(method)) {
-            throw new IllegalArgumentException(
-                    sm.getString("defaultInstanceManager.invalidInjection"));
+            throw new IllegalArgumentException(sm.getString("defaultInstanceManager.invalidInjection"));
         }
 
         Object lookedupResource;
@@ -611,8 +559,7 @@ public class DefaultInstanceManager implements InstanceManager {
         if ((normalizedName != null) && (normalizedName.length() > 0)) {
             lookedupResource = context.lookup(normalizedName);
         } else {
-            lookedupResource = context.lookup(
-                    clazz.getName() + "/" + Introspection.getPropertyName(method));
+            lookedupResource = context.lookup(clazz.getName() + "/" + Introspection.getPropertyName(method));
         }
 
         // This will always be a new Method instance
@@ -621,8 +568,7 @@ public class DefaultInstanceManager implements InstanceManager {
         method.invoke(instance, lookedupResource);
     }
 
-    private static void loadProperties(Set<String> classNames, String resourceName,
-            String messageKey, Log log) {
+    private static void loadProperties(Set<String> classNames, String resourceName, String messageKey, Log log) {
         Properties properties = new Properties();
         ClassLoader cl = DefaultInstanceManager.class.getClassLoader();
         try (InputStream is = cl.getResourceAsStream(resourceName)) {
@@ -641,29 +587,26 @@ public class DefaultInstanceManager implements InstanceManager {
             if ("restricted".equals(e.getValue())) {
                 classNames.add(e.getKey().toString());
             } else {
-                log.warn(sm.getString(
-                        "defaultInstanceManager.restrictedWrongValue",
-                        resourceName, e.getKey(), e.getValue()));
+                log.warn(sm.getString("defaultInstanceManager.restrictedWrongValue", resourceName, e.getKey(),
+                        e.getValue()));
             }
         }
     }
 
-    private static String normalize(String jndiName){
-        if(jndiName != null && jndiName.startsWith("java:comp/env/")){
+    private static String normalize(String jndiName) {
+        if (jndiName != null && jndiName.startsWith("java:comp/env/")) {
             return jndiName.substring(14);
         }
         return jndiName;
     }
 
-    private static Method getMethod(final Class<?> clazz,
-            final AnnotationCacheEntry entry) {
+    private static Method getMethod(final Class<?> clazz, final AnnotationCacheEntry entry) {
         Method result = null;
         if (Globals.IS_SECURITY_ENABLED) {
             result = AccessController.doPrivileged(new PrivilegedGetMethod(clazz, entry));
         } else {
             try {
-                result = clazz.getDeclaredMethod(
-                        entry.getAccessibleObjectName(), entry.getParamTypes());
+                result = clazz.getDeclaredMethod(entry.getAccessibleObjectName(), entry.getParamTypes());
             } catch (NoSuchMethodException e) {
                 // Should never happen. On that basis don't log it.
             }
@@ -671,8 +614,7 @@ public class DefaultInstanceManager implements InstanceManager {
         return result;
     }
 
-    private static Field getField(final Class<?> clazz,
-            final AnnotationCacheEntry entry) {
+    private static Field getField(final Class<?> clazz, final AnnotationCacheEntry entry) {
         Field result = null;
         if (Globals.IS_SECURITY_ENABLED) {
             result = AccessController.doPrivileged(new PrivilegedGetField(clazz, entry));
@@ -687,20 +629,15 @@ public class DefaultInstanceManager implements InstanceManager {
     }
 
 
-    private static Method findPostConstruct(Method currentPostConstruct,
-            String postConstructFromXml, Method method) {
-        return findLifecycleCallback(currentPostConstruct,
-            postConstructFromXml, method, PostConstruct.class);
+    private static Method findPostConstruct(Method currentPostConstruct, String postConstructFromXml, Method method) {
+        return findLifecycleCallback(currentPostConstruct, postConstructFromXml, method, PostConstruct.class);
     }
 
-    private static Method findPreDestroy(Method currentPreDestroy,
-        String preDestroyFromXml, Method method) {
-        return findLifecycleCallback(currentPreDestroy,
-            preDestroyFromXml, method, PreDestroy.class);
+    private static Method findPreDestroy(Method currentPreDestroy, String preDestroyFromXml, Method method) {
+        return findLifecycleCallback(currentPreDestroy, preDestroyFromXml, method, PreDestroy.class);
     }
 
-    private static Method findLifecycleCallback(Method currentMethod,
-            String methodNameFromXml, Method method,
+    private static Method findLifecycleCallback(Method currentMethod, String methodNameFromXml, Method method,
             Class<? extends Annotation> annotation) {
         Method result = currentMethod;
         if (methodNameFromXml != null) {
@@ -729,8 +666,7 @@ public class DefaultInstanceManager implements InstanceManager {
         private final String name;
         private final AnnotationCacheEntryType type;
 
-        public AnnotationCacheEntry(String accessibleObjectName,
-                Class<?>[] paramTypes, String name,
+        public AnnotationCacheEntry(String accessibleObjectName, Class<?>[] paramTypes, String name,
                 AnnotationCacheEntryType type) {
             this.accessibleObjectName = accessibleObjectName;
             this.paramTypes = paramTypes;
@@ -749,6 +685,7 @@ public class DefaultInstanceManager implements InstanceManager {
         public String getName() {
             return name;
         }
+
         public AnnotationCacheEntryType getType() {
             return type;
         }
@@ -797,8 +734,7 @@ public class DefaultInstanceManager implements InstanceManager {
         public Method run() {
             Method result = null;
             try {
-                result = clazz.getDeclaredMethod(
-                        entry.getAccessibleObjectName(), entry.getParamTypes());
+                result = clazz.getDeclaredMethod(entry.getAccessibleObjectName(), entry.getParamTypes());
             } catch (NoSuchMethodException e) {
                 // Should never happen. On that basis don't log it.
             }
diff --git a/java/org/apache/catalina/core/JniLifecycleListener.java b/java/org/apache/catalina/core/JniLifecycleListener.java
index 8e129da164..d1f3e797e0 100644
--- a/java/org/apache/catalina/core/JniLifecycleListener.java
+++ b/java/org/apache/catalina/core/JniLifecycleListener.java
@@ -26,14 +26,12 @@ import org.apache.tomcat.util.res.StringManager;
 /**
  * An implementation of LifeCycleListener that loads a native library into the JVM.
  * <p>
- * Native libraries are associated with the class loader of the class that loaded them,
- * and the same library may not be loaded by more than one class loader. Due to that
- * restriction, loading a native library from a Webapp's class loader makes it impossible
- * for other Webapps to load the native library.
+ * Native libraries are associated with the class loader of the class that loaded them, and the same library may not be
+ * loaded by more than one class loader. Due to that restriction, loading a native library from a Webapp's class loader
+ * makes it impossible for other Webapps to load the native library.
  * <p>
- * Loading the native library using this listener solves the issue as it is loaded
- * by a shared class loader (typically the Common class loader, but may vary in some
- * configurations).
+ * Loading the native library using this listener solves the issue as it is loaded by a shared class loader (typically
+ * the Common class loader, but may vary in some configurations).
  */
 public class JniLifecycleListener implements LifecycleListener {
 
diff --git a/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java b/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
index 314ebbca97..22b55b8508 100644
--- a/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
+++ b/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java
@@ -44,18 +44,14 @@ import org.w3c.dom.Document;
 import org.w3c.dom.ls.DOMImplementationLS;
 
 /**
- * Provide a workaround for known places where the Java Runtime environment can
- * cause a memory leak or lock files.
+ * Provide a workaround for known places where the Java Runtime environment can cause a memory leak or lock files.
  * <p>
- * Memory leaks occur when JRE code uses
- * the context class loader to load a singleton as this will cause a memory leak
- * if a web application class loader happens to be the context class loader at
- * the time. The work-around is to initialise these singletons when Tomcat's
- * common class loader is the context class loader.
+ * Memory leaks occur when JRE code uses the context class loader to load a singleton as this will cause a memory leak
+ * if a web application class loader happens to be the context class loader at the time. The work-around is to
+ * initialise these singletons when Tomcat's common class loader is the context class loader.
  * <p>
- * Locked files usually occur when a resource inside a JAR is accessed without
- * first disabling Jar URL connection caching. The workaround is to disable this
- * caching by default.
+ * Locked files usually occur when a resource inside a JAR is accessed without first disabling Jar URL connection
+ * caching. The workaround is to disable this caching by default.
  * <p>
  * This listener must only be nested within {@link Server} elements.
  */
@@ -64,166 +60,183 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
     private static final Log log = LogFactory.getLog(JreMemoryLeakPreventionListener.class);
     private static final StringManager sm = StringManager.getManager(JreMemoryLeakPreventionListener.class);
 
-    private static final String FORK_JOIN_POOL_THREAD_FACTORY_PROPERTY =
-            "java.util.concurrent.ForkJoinPool.common.threadFactory";
+    private static final String FORK_JOIN_POOL_THREAD_FACTORY_PROPERTY = "java.util.concurrent.ForkJoinPool.common.threadFactory";
     /**
-     * Protect against the memory leak caused when the first call to
-     * <code>sun.awt.AppContext.getAppContext()</code> is triggered by a web
-     * application. Defaults to <code>false</code> since
-     * {@link java.beans.Introspector#flushCaches()} no longer uses AppContext
-     * from 1.7.0_02 onwards. Also, from 1.7.0_25 onwards, calling this method
-     * requires a graphical environment and starts an AWT thread.
+     * Protect against the memory leak caused when the first call to <code>sun.awt.AppContext.getAppContext()</code> is
+     * triggered by a web application. Defaults to <code>false</code> since
+     * {@link java.beans.Introspector#flushCaches()} no longer uses AppContext from 1.7.0_02 onwards. Also, from
+     * 1.7.0_25 onwards, calling this method requires a graphical environment and starts an AWT thread.
      */
     private boolean appContextProtection = false;
-    public boolean isAppContextProtection() { return appContextProtection; }
+
+    public boolean isAppContextProtection() {
+        return appContextProtection;
+    }
+
     public void setAppContextProtection(boolean appContextProtection) {
         this.appContextProtection = appContextProtection;
     }
 
     /**
-     * Protect against the memory leak caused when the first call to
-     * <code>java.awt.Toolkit.getDefaultToolkit()</code> is triggered
-     * by a web application. Defaults to <code>false</code> because a new
-     * Thread is launched.
+     * Protect against the memory leak caused when the first call to <code>java.awt.Toolkit.getDefaultToolkit()</code>
+     * is triggered by a web application. Defaults to <code>false</code> because a new Thread is launched.
      */
     private boolean awtThreadProtection = false;
-    public boolean isAWTThreadProtection() { return awtThreadProtection; }
+
+    public boolean isAWTThreadProtection() {
+        return awtThreadProtection;
+    }
+
     public void setAWTThreadProtection(boolean awtThreadProtection) {
-      this.awtThreadProtection = awtThreadProtection;
+        this.awtThreadProtection = awtThreadProtection;
     }
 
     /**
-     * Protect against the memory leak caused when the first call to
-     * <code>sun.misc.GC.requestLatency(long)</code> is triggered by a web
-     * application. This first call will start a GC Daemon thread with the
-     * thread's context class loader configured to be the web application class
-     * loader. Defaults to <code>true</code>.
+     * Protect against the memory leak caused when the first call to <code>sun.misc.GC.requestLatency(long)</code> is
+     * triggered by a web application. This first call will start a GC Daemon thread with the thread's context class
+     * loader configured to be the web application class loader. Defaults to <code>true</code>.
      */
     private boolean gcDaemonProtection = true;
-    public boolean isGcDaemonProtection() { return gcDaemonProtection; }
+
+    public boolean isGcDaemonProtection() {
+        return gcDaemonProtection;
+    }
+
     public void setGcDaemonProtection(boolean gcDaemonProtection) {
         this.gcDaemonProtection = gcDaemonProtection;
     }
 
-     /**
-      * Protect against the memory leak caused when the first call to
-      * <code>javax.security.auth.Policy</code> is triggered by a web
-      * application. This first call populate a static variable with a reference
-      * to the context class loader. Defaults to <code>true</code>.
-      */
-     private boolean securityPolicyProtection = true;
-     public boolean isSecurityPolicyProtection() {
-         return securityPolicyProtection;
-     }
-     public void setSecurityPolicyProtection(boolean securityPolicyProtection) {
-         this.securityPolicyProtection = securityPolicyProtection;
-     }
+    /**
+     * Protect against the memory leak caused when the first call to <code>javax.security.auth.Policy</code> is
+     * triggered by a web application. This first call populate a static variable with a reference to the context class
+     * loader. Defaults to <code>true</code>.
+     */
+    private boolean securityPolicyProtection = true;
+
+    public boolean isSecurityPolicyProtection() {
+        return securityPolicyProtection;
+    }
+
+    public void setSecurityPolicyProtection(boolean securityPolicyProtection) {
+        this.securityPolicyProtection = securityPolicyProtection;
+    }
 
     /**
      * Protects against the memory leak caused when the first call to
-     * <code>javax.security.auth.login.Configuration</code> is triggered by a
-     * web application. This first call populate a static variable with a
-     * reference to the context class loader. Defaults to <code>true</code>.
+     * <code>javax.security.auth.login.Configuration</code> is triggered by a web application. This first call populate
+     * a static variable with a reference to the context class loader. Defaults to <code>true</code>.
      */
     private boolean securityLoginConfigurationProtection = true;
+
     public boolean isSecurityLoginConfigurationProtection() {
         return securityLoginConfigurationProtection;
     }
-    public void setSecurityLoginConfigurationProtection(
-            boolean securityLoginConfigurationProtection) {
+
+    public void setSecurityLoginConfigurationProtection(boolean securityLoginConfigurationProtection) {
         this.securityLoginConfigurationProtection = securityLoginConfigurationProtection;
     }
 
-     /**
-     * Protect against the memory leak, when the initialization of the
-     * Java Cryptography Architecture is triggered by initializing
-     * a MessageDigest during web application deployment.
-     * This will occasionally start a Token Poller thread with the thread's
-     * context class loader equal to the web application class loader.
-     * Instead we initialize JCA early.
-     * Defaults to <code>true</code>.
+    /**
+     * Protect against the memory leak, when the initialization of the Java Cryptography Architecture is triggered by
+     * initializing a MessageDigest during web application deployment. This will occasionally start a Token Poller
+     * thread with the thread's context class loader equal to the web application class loader. Instead we initialize
+     * JCA early. Defaults to <code>true</code>.
      */
     private boolean tokenPollerProtection = true;
-    public boolean isTokenPollerProtection() { return tokenPollerProtection; }
+
+    public boolean isTokenPollerProtection() {
+        return tokenPollerProtection;
+    }
+
     public void setTokenPollerProtection(boolean tokenPollerProtection) {
         this.tokenPollerProtection = tokenPollerProtection;
     }
 
     /**
-     * Protect against resources being read for JAR files and, as a side-effect,
-     * the JAR file becoming locked. Note this disables caching for all
-     * {@link URLConnection}s, regardless of type. Defaults to
-     * <code>true</code>.
+     * Protect against resources being read for JAR files and, as a side-effect, the JAR file becoming locked. Note this
+     * disables caching for all {@link URLConnection}s, regardless of type. Defaults to <code>true</code>.
      */
     private boolean urlCacheProtection = true;
-    public boolean isUrlCacheProtection() { return urlCacheProtection; }
+
+    public boolean isUrlCacheProtection() {
+        return urlCacheProtection;
+    }
+
     public void setUrlCacheProtection(boolean urlCacheProtection) {
         this.urlCacheProtection = urlCacheProtection;
     }
 
     /**
-     * XML parsing can pin a web application class loader in memory. There are
-     * multiple root causes for this. Some of these are particularly nasty as
-     * profilers may not identify any GC roots related to the leak. For example,
-     * with YourKit you need to ensure that HPROF format memory snapshots are
-     * used to be able to trace some of the leaks.
+     * XML parsing can pin a web application class loader in memory. There are multiple root causes for this. Some of
+     * these are particularly nasty as profilers may not identify any GC roots related to the leak. For example, with
+     * YourKit you need to ensure that HPROF format memory snapshots are used to be able to trace some of the leaks.
      */
     private boolean xmlParsingProtection = true;
-    public boolean isXmlParsingProtection() { return xmlParsingProtection; }
+
+    public boolean isXmlParsingProtection() {
+        return xmlParsingProtection;
+    }
+
     public void setXmlParsingProtection(boolean xmlParsingProtection) {
         this.xmlParsingProtection = xmlParsingProtection;
     }
 
     /**
-     * <code>com.sun.jndi.ldap.LdapPoolManager</code> class spawns a thread when
-     * it is initialized if the system property
-     * <code>com.sun.jndi.ldap.connect.pool.timeout</code> is greater than 0.
-     * That thread inherits the context class loader of the current thread, so
-     * that there may be a web application class loader leak if the web app
-     * is the first to use <code>LdapPoolManager</code>.
+     * <code>com.sun.jndi.ldap.LdapPoolManager</code> class spawns a thread when it is initialized if the system
+     * property <code>com.sun.jndi.ldap.connect.pool.timeout</code> is greater than 0. That thread inherits the context
+     * class loader of the current thread, so that there may be a web application class loader leak if the web app is
+     * the first to use <code>LdapPoolManager</code>.
      */
     private boolean ldapPoolProtection = true;
-    public boolean isLdapPoolProtection() { return ldapPoolProtection; }
+
+    public boolean isLdapPoolProtection() {
+        return ldapPoolProtection;
+    }
+
     public void setLdapPoolProtection(boolean ldapPoolProtection) {
         this.ldapPoolProtection = ldapPoolProtection;
     }
 
     /**
-     * The first access to {@link DriverManager} will trigger the loading of
-     * all {@link java.sql.Driver}s in the the current class loader. The web
-     * application level memory leak protection can take care of this in most
-     * cases but triggering the loading here has fewer side-effects.
+     * The first access to {@link DriverManager} will trigger the loading of all {@link java.sql.Driver}s in the the
+     * current class loader. The web application level memory leak protection can take care of this in most cases but
+     * triggering the loading here has fewer side-effects.
      */
     private boolean driverManagerProtection = true;
+
     public boolean isDriverManagerProtection() {
         return driverManagerProtection;
     }
+
     public void setDriverManagerProtection(boolean driverManagerProtection) {
         this.driverManagerProtection = driverManagerProtection;
     }
 
     /**
-     * {@link ForkJoinPool} creates a thread pool that, by default,
-     * creates threads that retain references to the thread context class
-     * loader.
+     * {@link ForkJoinPool} creates a thread pool that, by default, creates threads that retain references to the thread
+     * context class loader.
      */
     private boolean forkJoinCommonPoolProtection = true;
+
     public boolean getForkJoinCommonPoolProtection() {
         return forkJoinCommonPoolProtection;
     }
+
     public void setForkJoinCommonPoolProtection(boolean forkJoinCommonPoolProtection) {
         this.forkJoinCommonPoolProtection = forkJoinCommonPoolProtection;
     }
 
     /**
-     * List of comma-separated fully qualified class names to load and initialize during
-     * the startup of this Listener. This allows to pre-load classes that are known to
-     * provoke classloader leaks if they are loaded during a request processing.
+     * List of comma-separated fully qualified class names to load and initialize during the startup of this Listener.
+     * This allows to pre-load classes that are known to provoke classloader leaks if they are loaded during a request
+     * processing.
      */
     private String classesToInitialize = null;
+
     public String getClassesToInitialize() {
         return classesToInitialize;
     }
+
     public void setClassesToInitialize(String classesToInitialize) {
         this.classesToInitialize = classesToInitialize;
     }
@@ -234,20 +247,16 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
         // Initialise these classes when Tomcat starts
         if (Lifecycle.BEFORE_INIT_EVENT.equals(event.getType())) {
             if (!(event.getLifecycle() instanceof Server)) {
-                log.warn(sm.getString("listener.notServer",
-                        event.getLifecycle().getClass().getSimpleName()));
+                log.warn(sm.getString("listener.notServer", event.getLifecycle().getClass().getSimpleName()));
             }
 
             /*
-             * First call to this loads all drivers visible to the current class
-             * loader and its parents.
+             * First call to this loads all drivers visible to the current class loader and its parents.
              *
-             * Note: This is called before the context class loader is changed
-             *       because we want any drivers located in CATALINA_HOME/lib
-             *       and/or CATALINA_HOME/lib to be visible to DriverManager.
-             *       Users wishing to avoid having JDBC drivers loaded by this
-             *       class loader should add the JDBC driver(s) to the class
-             *       path so they are loaded by the system class loader.
+             * Note: This is called before the context class loader is changed because we want any drivers located in
+             * CATALINA_HOME/lib and/or CATALINA_HOME/lib to be visible to DriverManager. Users wishing to avoid having
+             * JDBC drivers loaded by this class loader should add the JDBC driver(s) to the class path so they are
+             * loaded by the system class loader.
              */
             if (driverManagerProtection) {
                 DriverManager.getDrivers();
@@ -258,26 +267,18 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
             try {
                 // Use the system classloader as the victim for all this
                 // ClassLoader pinning we're about to do.
-                Thread.currentThread().setContextClassLoader(
-                        ClassLoader.getSystemClassLoader());
+                Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
 
                 /*
-                 * Several components end up calling:
-                 * sun.awt.AppContext.getAppContext()
+                 * Several components end up calling: sun.awt.AppContext.getAppContext()
                  *
-                 * Those libraries / components known to trigger memory leaks
-                 * due to eventual calls to getAppContext() are:
-                 * - Google Web Toolkit via its use of javax.imageio
-                 * - Tomcat via its use of java.beans.Introspector.flushCaches()
-                 *   in 1.7.0 to 1.7.0_01. From 1.7.0_02 onwards use of
-                 *   AppContext by Introspector.flushCaches() was replaced with
-                 *   ThreadGroupContext
-                 * - others TBD
+                 * Those libraries / components known to trigger memory leaks due to eventual calls to getAppContext()
+                 * are: - Google Web Toolkit via its use of javax.imageio - Tomcat via its use of
+                 * java.beans.Introspector.flushCaches() in 1.7.0 to 1.7.0_01. From 1.7.0_02 onwards use of AppContext
+                 * by Introspector.flushCaches() was replaced with ThreadGroupContext - others TBD
                  *
-                 * From 1.7.0_25 onwards, a call to
-                 * sun.awt.AppContext.getAppContext() results in a thread being
-                 * started named AWT-AppKit that requires a graphic environment
-                 * to be available.
+                 * From 1.7.0_25 onwards, a call to sun.awt.AppContext.getAppContext() results in a thread being started
+                 * named AWT-AppKit that requires a graphic environment to be available.
                  */
 
                 // Trigger a call to sun.awt.AppContext.getAppContext(). This
@@ -294,94 +295,79 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
                 }
 
                 /*
-                 * Several components end up calling
-                 * sun.misc.GC.requestLatency(long) which creates a daemon
-                 * thread without setting the TCCL.
+                 * Several components end up calling sun.misc.GC.requestLatency(long) which creates a daemon thread
+                 * without setting the TCCL.
                  *
-                 * Those libraries / components known to trigger memory leaks
-                 * due to eventual calls to requestLatency(long) are:
-                 * - javax.management.remote.rmi.RMIConnectorServer.start()
+                 * Those libraries / components known to trigger memory leaks due to eventual calls to
+                 * requestLatency(long) are: - javax.management.remote.rmi.RMIConnectorServer.start()
                  *
-                 * Note: Long.MAX_VALUE is a special case that causes the thread
-                 *       to terminate
+                 * Note: Long.MAX_VALUE is a special case that causes the thread to terminate
                  *
                  */
                 if (gcDaemonProtection && !JreCompat.isJre9Available()) {
                     try {
                         Class<?> clazz = Class.forName("sun.misc.GC");
-                        Method method = clazz.getDeclaredMethod(
-                                "requestLatency",
-                                new Class[] {long.class});
+                        Method method = clazz.getDeclaredMethod("requestLatency", new Class[] { long.class });
                         method.invoke(null, Long.valueOf(Long.MAX_VALUE - 1));
                     } catch (ClassNotFoundException e) {
                         if (JreVendor.IS_ORACLE_JVM) {
-                            log.error(sm.getString(
-                                    "jreLeakListener.gcDaemonFail"), e);
+                            log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
                         } else {
-                            log.debug(sm.getString(
-                                    "jreLeakListener.gcDaemonFail"), e);
+                            log.debug(sm.getString("jreLeakListener.gcDaemonFail"), e);
                         }
-                    } catch (SecurityException | NoSuchMethodException | IllegalArgumentException |
-                            IllegalAccessException e) {
-                        log.error(sm.getString("jreLeakListener.gcDaemonFail"),
-                                e);
+                    } catch (SecurityException | NoSuchMethodException | IllegalArgumentException
+                            | IllegalAccessException e) {
+                        log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
                     } catch (InvocationTargetException e) {
                         ExceptionUtils.handleThrowable(e.getCause());
-                        log.error(sm.getString("jreLeakListener.gcDaemonFail"),
-                                e);
+                        log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
                     }
                 }
 
                 /*
-                 * Calling getPolicy retains a static reference to the context
-                 * class loader.
+                 * Calling getPolicy retains a static reference to the context class loader.
                  */
                 if (securityPolicyProtection && !JreCompat.isJre8Available()) {
                     try {
                         // Policy.getPolicy();
-                        Class<?> policyClass = Class
-                                .forName("javax.security.auth.Policy");
+                        Class<?> policyClass = Class.forName("javax.security.auth.Policy");
                         Method method = policyClass.getMethod("getPolicy");
                         method.invoke(null);
-                    } catch(ClassNotFoundException e) {
+                    } catch (ClassNotFoundException e) {
                         // Ignore. The class is deprecated.
-                    } catch(SecurityException e) {
+                    } catch (SecurityException e) {
                         // Ignore. Don't need call to getPolicy() to be
                         // successful, just need to trigger static initializer.
                     } catch (NoSuchMethodException e) {
-                        log.warn(sm.getString("jreLeakListener.authPolicyFail"),
-                                e);
+                        log.warn(sm.getString("jreLeakListener.authPolicyFail"), e);
                     } catch (IllegalArgumentException e) {
-                        log.warn(sm.getString("jreLeakListener.authPolicyFail"),
-                                e);
+                        log.warn(sm.getString("jreLeakListener.authPolicyFail"), e);
                     } catch (IllegalAccessException e) {
-                        log.warn(sm.getString("jreLeakListener.authPolicyFail"),
-                                e);
+                        log.warn(sm.getString("jreLeakListener.authPolicyFail"), e);
                     } catch (InvocationTargetException e) {
                         ExceptionUtils.handleThrowable(e.getCause());
-                        log.warn(sm.getString("jreLeakListener.authPolicyFail"),
-                                e);
+                        log.warn(sm.getString("jreLeakListener.authPolicyFail"), e);
                     }
                 }
 
 
                 /*
-                 * Initializing javax.security.auth.login.Configuration retains a static reference to the context
-                 * class loader.
+                 * Initializing javax.security.auth.login.Configuration retains a static reference to the context class
+                 * loader.
                  */
                 if (securityLoginConfigurationProtection && !JreCompat.isJre8Available()) {
                     try {
-                        Class.forName("javax.security.auth.login.Configuration", true, ClassLoader.getSystemClassLoader());
-                    } catch(ClassNotFoundException e) {
+                        Class.forName("javax.security.auth.login.Configuration", true,
+                                ClassLoader.getSystemClassLoader());
+                    } catch (ClassNotFoundException e) {
                         // Ignore
                     }
                 }
 
                 /*
-                 * Creating a MessageDigest during web application startup
-                 * initializes the Java Cryptography Architecture. Under certain
-                 * conditions this starts a Token poller thread with TCCL equal
-                 * to the web application class loader.
+                 * Creating a MessageDigest during web application startup initializes the Java Cryptography
+                 * Architecture. Under certain conditions this starts a Token poller thread with TCCL equal to the web
+                 * application class loader.
                  *
                  * Instead we initialize JCA right now.
                  *
@@ -392,18 +378,15 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
                 }
 
                 /*
-                 * Several components end up opening JarURLConnections without
-                 * first disabling caching. This effectively locks the file.
-                 * Whilst more noticeable and harder to ignore on Windows, it
-                 * affects all operating systems.
+                 * Several components end up opening JarURLConnections without first disabling caching. This effectively
+                 * locks the file. Whilst more noticeable and harder to ignore on Windows, it affects all operating
+                 * systems.
                  *
-                 * Those libraries/components known to trigger this issue
-                 * include:
-                 * - log4j versions 1.2.15 and earlier
-                 * - javax.xml.bind.JAXBContext.newInstance()
+                 * Those libraries/components known to trigger this issue include: - log4j versions 1.2.15 and earlier -
+                 * javax.xml.bind.JAXBContext.newInstance()
                  *
-                 * Java 9 onwards disables caching for JAR URLConnections
-                 * Java 8 and earlier disables caching for all URLConnections
+                 * Java 9 onwards disables caching for JAR URLConnections Java 8 and earlier disables caching for all
+                 * URLConnections
                  */
 
                 // Set the default URL caching policy to not to cache
@@ -432,15 +415,13 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
                         // com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl
                         Document document = documentBuilder.newDocument();
                         document.createElement("dummy");
-                        DOMImplementationLS implementation =
-                                (DOMImplementationLS)document.getImplementation();
+                        DOMImplementationLS implementation = (DOMImplementationLS) document.getImplementation();
                         implementation.createLSSerializer().writeToString(document);
                         // Issue 1
                         // com.sun.org.apache.xerces.internal.dom.DOMNormalizer
                         document.normalize();
                     } catch (ParserConfigurationException e) {
-                        log.error(sm.getString("jreLeakListener.xmlParseFail"),
-                                e);
+                        log.error(sm.getString("jreLeakListener.xmlParseFail"), e);
                     }
                 }
 
@@ -449,22 +430,18 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
                         Class.forName("com.sun.jndi.ldap.LdapPoolManager");
                     } catch (ClassNotFoundException e) {
                         if (JreVendor.IS_ORACLE_JVM) {
-                            log.error(sm.getString(
-                                    "jreLeakListener.ldapPoolManagerFail"), e);
+                            log.error(sm.getString("jreLeakListener.ldapPoolManagerFail"), e);
                         } else {
-                            log.debug(sm.getString(
-                                    "jreLeakListener.ldapPoolManagerFail"), e);
+                            log.debug(sm.getString("jreLeakListener.ldapPoolManagerFail"), e);
                         }
                     }
                 }
 
                 /*
-                 * Present in Java 7 onwards
-                 * Work-around only available in Java 8.
-                 * Fixed in Java 9 (from early access build 156)
+                 * Present in Java 7 onwards Work-around only available in Java 8. Fixed in Java 9 (from early access
+                 * build 156)
                  */
-                if (forkJoinCommonPoolProtection && JreCompat.isJre8Available() &&
-                        !JreCompat.isJre9Available()) {
+                if (forkJoinCommonPoolProtection && JreCompat.isJre8Available() && !JreCompat.isJre9Available()) {
                     // Don't override any explicitly set property
                     if (System.getProperty(FORK_JOIN_POOL_THREAD_FACTORY_PROPERTY) == null) {
                         System.setProperty(FORK_JOIN_POOL_THREAD_FACTORY_PROPERTY,
@@ -473,16 +450,13 @@ public class JreMemoryLeakPreventionListener implements LifecycleListener {
                 }
 
                 if (classesToInitialize != null) {
-                    StringTokenizer strTok =
-                        new StringTokenizer(classesToInitialize, ", \r\n\t");
+                    StringTokenizer strTok = new StringTokenizer(classesToInitialize, ", \r\n\t");
                     while (strTok.hasMoreTokens()) {
                         String classNameToLoad = strTok.nextToken();
                         try {
                             Class.forName(classNameToLoad);
                         } catch (ClassNotFoundException e) {
-                            log.error(
-                                sm.getString("jreLeakListener.classToInitializeFail",
-                                    classNameToLoad), e);
+                            log.error(sm.getString("jreLeakListener.classToInitializeFail", classNameToLoad), e);
                             // continue with next class to load
                         }
                     }
diff --git a/java/org/apache/catalina/core/NamingContextListener.java b/java/org/apache/catalina/core/NamingContextListener.java
index 90cde74adc..d8b5c3cdbb 100644
--- a/java/org/apache/catalina/core/NamingContextListener.java
+++ b/java/org/apache/catalina/core/NamingContextListener.java
@@ -77,13 +77,11 @@ import org.apache.tomcat.util.res.StringManager;
 
 
 /**
- * Helper class used to initialize and populate the JNDI context associated
- * with each context and server.
+ * Helper class used to initialize and populate the JNDI context associated with each context and server.
  *
  * @author Remy Maucherat
  */
-public class NamingContextListener
-    implements LifecycleListener, ContainerListener, PropertyChangeListener {
+public class NamingContextListener implements LifecycleListener, ContainerListener, PropertyChangeListener {
 
     private static final Log log = LogFactory.getLog(NamingContextListener.class);
     protected static final StringManager sm = StringManager.getManager(NamingContextListener.class);
@@ -144,8 +142,7 @@ public class NamingContextListener
 
 
     /**
-     * Determines if an attempt to write to a read-only context results in an
-     * exception or if the request is ignored.
+     * Determines if an attempt to write to a read-only context results in an exception or if the request is ignored.
      */
     private boolean exceptionOnFailedWrite = true;
 
@@ -153,8 +150,8 @@ public class NamingContextListener
     // ------------------------------------------------------------- Properties
 
     /**
-     * @return whether or not an attempt to modify the JNDI context will trigger
-     * an exception or if the request will be ignored.
+     * @return whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be
+     *             ignored.
      */
     public boolean getExceptionOnFailedWrite() {
         return exceptionOnFailedWrite;
@@ -162,10 +159,10 @@ public class NamingContextListener
 
 
     /**
-     * Controls whether or not an attempt to modify the JNDI context will
-     * trigger an exception or if the request will be ignored.
+     * Controls whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be
+     * ignored.
      *
-     * @param exceptionOnFailedWrite    The new value
+     * @param exceptionOnFailedWrite The new value
      */
     public void setExceptionOnFailedWrite(boolean exceptionOnFailedWrite) {
         this.exceptionOnFailedWrite = exceptionOnFailedWrite;
@@ -232,13 +229,12 @@ public class NamingContextListener
                 ContextAccessController.setSecurityToken(getName(), token);
                 ContextAccessController.setSecurityToken(container, token);
                 ContextBindings.bindContext(container, namingContext, token);
-                if( log.isDebugEnabled() ) {
-                    log.debug("Bound " + container );
+                if (log.isDebugEnabled()) {
+                    log.debug("Bound " + container);
                 }
 
                 // Configure write when read-only behaviour
-                namingContext.setExceptionOnFailedWrite(
-                        getExceptionOnFailedWrite());
+                namingContext.setExceptionOnFailedWrite(getExceptionOnFailedWrite());
 
                 // Setting the context in read/write mode
                 ContextAccessController.setWritable(getName(), token);
@@ -246,8 +242,7 @@ public class NamingContextListener
                 try {
                     createNamingContext();
                 } catch (NamingException e) {
-                    log.error
-                        (sm.getString("naming.namingContextCreationFailed", e));
+                    log.error(sm.getString("naming.namingContextCreationFailed", e));
                 }
 
                 namingResources.addPropertyChangeListener(this);
@@ -265,17 +260,14 @@ public class NamingContextListener
                 }
 
                 if (container instanceof Server) {
-                    org.apache.naming.factory.ResourceLinkFactory.setGlobalContext
-                        (namingContext);
+                    org.apache.naming.factory.ResourceLinkFactory.setGlobalContext(namingContext);
                     try {
-                        ContextBindings.bindClassLoader(container, token,
-                                this.getClass().getClassLoader());
+                        ContextBindings.bindClassLoader(container, token, this.getClass().getClassLoader());
                     } catch (NamingException e) {
                         log.error(sm.getString("naming.bindFailed", e));
                     }
                     if (container instanceof StandardServer) {
-                        ((StandardServer) container).setGlobalNamingContext
-                            (namingContext);
+                        ((StandardServer) container).setGlobalNamingContext(namingContext);
                     }
                 }
 
@@ -301,8 +293,7 @@ public class NamingContextListener
                 }
 
                 if (container instanceof Server) {
-                    ContextBindings.unbindClassLoader(container, token,
-                            this.getClass().getClassLoader());
+                    ContextBindings.unbindClassLoader(container, token, this.getClass().getClassLoader());
                 }
 
                 namingResources.removePropertyChangeListener(this);
@@ -344,9 +335,8 @@ public class NamingContextListener
      *
      * @param event ContainerEvent that has occurred
      *
-     * @deprecated The {@link ContainerListener} interface and implementing
-     *             methods will be removed from this class for Tomcat 10
-     *             onwards.
+     * @deprecated The {@link ContainerListener} interface and implementing methods will be removed from this class for
+     *                 Tomcat 10 onwards.
      */
     @Deprecated
     @Override
@@ -376,9 +366,7 @@ public class NamingContextListener
             // Setting the context in read/write mode
             ContextAccessController.setWritable(getName(), token);
 
-            processGlobalResourcesChange(event.getPropertyName(),
-                                         event.getOldValue(),
-                                         event.getNewValue());
+            processGlobalResourcesChange(event.getPropertyName(), event.getOldValue(), event.getNewValue());
 
             // Setting the context in read only mode
             ContextAccessController.setReadOnly(getName());
@@ -392,16 +380,14 @@ public class NamingContextListener
 
 
     /**
-     * Process a property change on the naming resources, by making the
-     * corresponding addition or removal to the associated JNDI context.
+     * Process a property change on the naming resources, by making the corresponding addition or removal to the
+     * associated JNDI context.
      *
-     * @param name Property name of the change to be processed
+     * @param name     Property name of the change to be processed
      * @param oldValue The old value (or <code>null</code> if adding)
      * @param newValue The new value (or <code>null</code> if removing)
      */
-    private void processGlobalResourcesChange(String name,
-                                              Object oldValue,
-                                              Object newValue) {
+    private void processGlobalResourcesChange(String name, Object oldValue, Object newValue) {
 
         if (name.equals("ejb")) {
             if (oldValue != null) {
@@ -470,15 +456,13 @@ public class NamingContextListener
             }
         } else if (name.equals("resourceEnvRef")) {
             if (oldValue != null) {
-                ContextResourceEnvRef resourceEnvRef =
-                    (ContextResourceEnvRef) oldValue;
+                ContextResourceEnvRef resourceEnvRef = (ContextResourceEnvRef) oldValue;
                 if (resourceEnvRef.getName() != null) {
                     removeResourceEnvRef(resourceEnvRef.getName());
                 }
             }
             if (newValue != null) {
-                ContextResourceEnvRef resourceEnvRef =
-                    (ContextResourceEnvRef) newValue;
+                ContextResourceEnvRef resourceEnvRef = (ContextResourceEnvRef) newValue;
                 if (resourceEnvRef.getName() != null) {
                     addResourceEnvRef(resourceEnvRef);
                 }
@@ -518,8 +502,7 @@ public class NamingContextListener
     /**
      * Create and initialize the JNDI naming context.
      */
-    private void createNamingContext()
-        throws NamingException {
+    private void createNamingContext() throws NamingException {
 
         // Creating the comp subcontext
         if (container instanceof Server) {
@@ -542,8 +525,7 @@ public class NamingContextListener
         }
 
         // Resource links
-        ContextResourceLink[] resourceLinks =
-            namingResources.findResourceLinks();
+        ContextResourceLink[] resourceLinks = namingResources.findResourceLinks();
         for (i = 0; i < resourceLinks.length; i++) {
             addResourceLink(resourceLinks[i]);
         }
@@ -561,8 +543,7 @@ public class NamingContextListener
         }
 
         // Environment entries
-        ContextEnvironment[] contextEnvironments =
-            namingResources.findEnvironments();
+        ContextEnvironment[] contextEnvironments = namingResources.findEnvironments();
         for (i = 0; i < contextEnvironments.length; i++) {
             addEnvironment(contextEnvironments[i]);
         }
@@ -611,8 +592,7 @@ public class NamingContextListener
         // Binding the resources directory context
         if (container instanceof Context) {
             try {
-                compCtx.bind("Resources",
-                             ((Context) container).getResources());
+                compCtx.bind("Resources", ((Context) container).getResources());
             } catch (NamingException e) {
                 log.error(sm.getString("naming.bindFailed", e));
             }
@@ -622,15 +602,15 @@ public class NamingContextListener
 
 
     /**
-     * Create an <code>ObjectName</code> for this
-     * <code>ContextResource</code> object.
+     * Create an <code>ObjectName</code> for this <code>ContextResource</code> object.
      *
      * @param resource The resource
+     *
      * @return ObjectName The object name
+     *
      * @exception MalformedObjectNameException if a name cannot be created
      */
-    protected ObjectName createObjectName(ContextResource resource)
-        throws MalformedObjectNameException {
+    protected ObjectName createObjectName(ContextResource resource) throws MalformedObjectNameException {
 
         String domain = null;
         if (container instanceof StandardServer) {
@@ -645,20 +625,16 @@ public class NamingContextListener
         ObjectName name = null;
         String quotedResourceName = ObjectName.quote(resource.getName());
         if (container instanceof Server) {
-            name = new ObjectName(domain + ":type=DataSource" +
-                        ",class=" + resource.getType() +
-                        ",name=" + quotedResourceName);
+            name = new ObjectName(
+                    domain + ":type=DataSource" + ",class=" + resource.getType() + ",name=" + quotedResourceName);
         } else if (container instanceof Context) {
-            String contextName = ((Context)container).getName();
+            String contextName = ((Context) container).getName();
             if (!contextName.startsWith("/")) {
                 contextName = "/" + contextName;
             }
-            Host host = (Host) ((Context)container).getParent();
-            name = new ObjectName(domain + ":type=DataSource" +
-                    ",host=" + host.getName() +
-                    ",context=" + contextName +
-                    ",class=" + resource.getType() +
-                    ",name=" + quotedResourceName);
+            Host host = (Host) ((Context) container).getParent();
+            name = new ObjectName(domain + ":type=DataSource" + ",host=" + host.getName() + ",context=" + contextName +
+                    ",class=" + resource.getType() + ",name=" + quotedResourceName);
         }
 
         return name;
@@ -764,8 +740,7 @@ public class NamingContextListener
                 } else {
                     value = constructEnvEntry(env.getType(), env.getValue());
                     if (value == null) {
-                        log.error(sm.getString(
-                                "naming.invalidEnvEntryType", env.getName()));
+                        log.error(sm.getString("naming.invalidEnvEntryType", env.getName()));
                     }
                 }
             } catch (IllegalArgumentException e) {
@@ -793,8 +768,8 @@ public class NamingContextListener
             Class<?> clazz = Class.forName(type);
             Constructor<?> c = null;
             try {
-                 c = clazz.getConstructor(String.class);
-                 return c.newInstance(value);
+                c = clazz.getConstructor(String.class);
+                return c.newInstance(value);
             } catch (NoSuchMethodException e) {
                 // Ignore
             }
@@ -861,18 +836,15 @@ public class NamingContextListener
                 }
                 if (wsdlURL == null) {
                     try {
-                        wsdlURL = ((Context) container).getServletContext().getResource(
-                                service.getWsdlfile());
+                        wsdlURL = ((Context) container).getServletContext().getResource(service.getWsdlfile());
                     } catch (MalformedURLException e) {
                         // Ignore and carry on
                     }
                 }
                 if (wsdlURL == null) {
                     try {
-                        wsdlURL = ((Context) container).getServletContext().getResource(
-                                "/" + service.getWsdlfile());
-                        log.debug("  Changing service ref wsdl file for /"
-                                    + service.getWsdlfile());
+                        wsdlURL = ((Context) container).getServletContext().getResource("/" + service.getWsdlfile());
+                        log.debug("  Changing service ref wsdl file for /" + service.getWsdlfile());
                     } catch (MalformedURLException e) {
                         log.error(sm.getString("naming.wsdlFailed", e));
                     }
@@ -895,18 +867,17 @@ public class NamingContextListener
                 }
                 if (jaxrpcURL == null) {
                     try {
-                        jaxrpcURL = ((Context) container).getServletContext().getResource(
-                                service.getJaxrpcmappingfile());
+                        jaxrpcURL = ((Context) container).getServletContext()
+                                .getResource(service.getJaxrpcmappingfile());
                     } catch (MalformedURLException e) {
                         // Ignore and carry on
                     }
                 }
                 if (jaxrpcURL == null) {
                     try {
-                        jaxrpcURL = ((Context) container).getServletContext().getResource(
-                                "/" + service.getJaxrpcmappingfile());
-                        log.debug("  Changing service ref jaxrpc file for /"
-                                    + service.getJaxrpcmappingfile());
+                        jaxrpcURL = ((Context) container).getServletContext()
+                                .getResource("/" + service.getJaxrpcmappingfile());
+                        log.debug("  Changing service ref jaxrpc file for /" + service.getJaxrpcmappingfile());
                     } catch (MalformedURLException e) {
                         log.error(sm.getString("naming.wsdlFailed", e));
                     }
@@ -919,9 +890,8 @@ public class NamingContextListener
             }
 
             // Create a reference to the resource.
-            ref = new ServiceRef(service.getName(), service.getInterface(),
-                    service.getServiceqname(), service.getWsdlfile(),
-                    service.getJaxrpcmappingfile());
+            ref = new ServiceRef(service.getName(), service.getInterface(), service.getServiceqname(),
+                    service.getWsdlfile(), service.getJaxrpcmappingfile());
 
             // Adding the additional port-component-ref, if any
             Iterator<String> portcomponent = service.getServiceendpoints();
@@ -986,8 +956,8 @@ public class NamingContextListener
 
         if (ref == null) {
             // Create a reference to the resource.
-            ref = new ResourceRef(resource.getType(), resource.getDescription(),
-                    resource.getScope(), resource.getAuth(), resource.getSingleton());
+            ref = new ResourceRef(resource.getType(), resource.getDescription(), resource.getScope(),
+                    resource.getAuth(), resource.getSingleton());
             // Adding the additional parameters, if any
             Iterator<String> params = resource.listProperties();
             while (params.hasNext()) {
@@ -1008,9 +978,8 @@ public class NamingContextListener
             log.error(sm.getString("naming.bindFailed", e));
         }
 
-        if (("javax.sql.DataSource".equals(ref.getClassName())  ||
-            "javax.sql.XADataSource".equals(ref.getClassName())) &&
-                resource.getSingleton()) {
+        if (("javax.sql.DataSource".equals(ref.getClassName()) ||
+                "javax.sql.XADataSource".equals(ref.getClassName())) && resource.getSingleton()) {
             Object actualResource = null;
             try {
                 ObjectName on = createObjectName(resource);
@@ -1071,20 +1040,18 @@ public class NamingContextListener
     public void addResourceLink(ContextResourceLink resourceLink) {
 
         // Create a reference to the resource.
-        Reference ref = new ResourceLinkRef
-            (resourceLink.getType(), resourceLink.getGlobal(), resourceLink.getFactory(), null);
+        Reference ref = new ResourceLinkRef(resourceLink.getType(), resourceLink.getGlobal(), resourceLink.getFactory(),
+                null);
         Iterator<String> i = resourceLink.listProperties();
         while (i.hasNext()) {
             String key = i.next();
             Object val = resourceLink.getProperty(key);
-            if (val!=null) {
+            if (val != null) {
                 StringRefAddr refAddr = new StringRefAddr(key, val.toString());
                 ref.add(refAddr);
             }
         }
-        javax.naming.Context ctx =
-            "UserTransaction".equals(resourceLink.getName())
-            ? compCtx : envCtx;
+        javax.naming.Context ctx = "UserTransaction".equals(resourceLink.getName()) ? compCtx : envCtx;
         try {
             if (log.isDebugEnabled()) {
                 log.debug("  Adding resource link " + resourceLink.getName());
@@ -1095,8 +1062,8 @@ public class NamingContextListener
             log.error(sm.getString("naming.bindFailed", e));
         }
 
-        ResourceLinkFactory.registerGlobalResourceAccess(
-                getGlobalNamingContext(), resourceLink.getName(), resourceLink.getGlobal());
+        ResourceLinkFactory.registerGlobalResourceAccess(getGlobalNamingContext(), resourceLink.getName(),
+                resourceLink.getGlobal());
     }
 
 
@@ -1164,8 +1131,7 @@ public class NamingContextListener
     /**
      * Remove the specified message destination ref from the naming context.
      *
-     * @param name the name of the message destination ref which should be
-     *             removed
+     * @param name the name of the message destination ref which should be removed
      */
     public void removeMessageDestinationRef(String name) {
 
@@ -1216,11 +1182,9 @@ public class NamingContextListener
 
 
     /**
-     * Remove the specified resource environment reference from the naming
-     * context.
+     * Remove the specified resource environment reference from the naming context.
      *
-     * @param name the name of the resource environment reference which should
-     *             be removed
+     * @param name the name of the resource environment reference which should be removed
      */
     public void removeResourceEnvRef(String name) {
 
@@ -1253,8 +1217,7 @@ public class NamingContextListener
     /**
      * Create all intermediate subcontexts.
      */
-    private void createSubcontexts(javax.naming.Context ctx, String name)
-        throws NamingException {
+    private void createSubcontexts(javax.naming.Context ctx, String name) throws NamingException {
         javax.naming.Context currentContext = ctx;
         StringTokenizer tokenizer = new StringTokenizer(name, "/");
         while (tokenizer.hasMoreTokens()) {
@@ -1265,8 +1228,7 @@ public class NamingContextListener
                 } catch (NamingException e) {
                     // Silent catch. Probably an object is already bound in
                     // the context.
-                    currentContext =
-                        (javax.naming.Context) currentContext.lookup(token);
+                    currentContext = (javax.naming.Context) currentContext.lookup(token);
                 }
             }
         }
@@ -1277,6 +1239,7 @@ public class NamingContextListener
      * Gets look up reference from resource if exist.
      *
      * @param resourceBase resource base object
+     *
      * @return lookup ref
      */
     private LookupRef lookForLookupRef(ResourceBase resourceBase) {
diff --git a/java/org/apache/catalina/core/StandardContext.java b/java/org/apache/catalina/core/StandardContext.java
index ae2c5b821c..7bf004d59d 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -138,15 +138,13 @@ import org.apache.tomcat.util.security.PrivilegedGetTccl;
 import org.apache.tomcat.util.security.PrivilegedSetTccl;
 
 /**
- * Standard implementation of the <b>Context</b> interface.  Each
- * child container must be a Wrapper implementation to process the
- * requests directed to a particular servlet.
+ * Standard implementation of the <b>Context</b> interface. Each child container must be a Wrapper implementation to
+ * process the requests directed to a particular servlet.
  *
  * @author Craig R. McClanahan
  * @author Remy Maucherat
  */
-public class StandardContext extends ContainerBase
-        implements Context, NotificationEmitter {
+public class StandardContext extends ContainerBase implements Context, NotificationEmitter {
 
     private static final Log log = LogFactory.getLog(StandardContext.class);
 
@@ -174,15 +172,14 @@ public class StandardContext extends ContainerBase
     // ----------------------------------------------------- Instance Variables
 
     /**
-     * Allow multipart/form-data requests to be parsed even when the
-     * target servlet doesn't specify @MultipartConfig or have a
-     * &lt;multipart-config&gt; element.
+     * Allow multipart/form-data requests to be parsed even when the target servlet doesn't specify @MultipartConfig or
+     * have a &lt;multipart-config&gt; element.
      */
     protected boolean allowCasualMultipartParsing = false;
 
     /**
-     * Control whether remaining request data will be read
-     * (swallowed) even if the request violates a data size constraint.
+     * Control whether remaining request data will be read (swallowed) even if the request violates a data size
+     * constraint.
      */
     private boolean swallowAbortedUploads = true;
 
@@ -205,49 +202,43 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The set of application listener class names configured for this
-     * application, in the order they were encountered in the resulting merged
-     * web.xml file.
+     * The set of application listener class names configured for this application, in the order they were encountered
+     * in the resulting merged web.xml file.
      */
     private String applicationListeners[] = new String[0];
 
     private final Object applicationListenersLock = new Object();
 
     /**
-     * The set of application listeners that are required to have limited access
-     * to ServletContext methods. See Servlet 3.1 section 4.4.
+     * The set of application listeners that are required to have limited access to ServletContext methods. See Servlet
+     * 3.1 section 4.4.
      */
     private final Set<Object> noPluggabilityListeners = new HashSet<>();
 
     /**
-     * The list of instantiated application event listener objects. Note that
-     * SCIs and other code may use the pluggability APIs to add listener
-     * instances directly to this list before the application starts.
+     * The list of instantiated application event listener objects. Note that SCIs and other code may use the
+     * pluggability APIs to add listener instances directly to this list before the application starts.
      */
     private List<Object> applicationEventListenersList = new CopyOnWriteArrayList<>();
 
 
     /**
-     * The set of instantiated application lifecycle listener objects. Note that
-     * SCIs and other code may use the pluggability APIs to add listener
-     * instances directly to this list before the application starts.
+     * The set of instantiated application lifecycle listener objects. Note that SCIs and other code may use the
+     * pluggability APIs to add listener instances directly to this list before the application starts.
      */
-    private Object applicationLifecycleListenersObjects[] =
-        new Object[0];
+    private Object applicationLifecycleListenersObjects[] = new Object[0];
 
 
     /**
      * The ordered set of ServletContainerInitializers for this web application.
      */
-    private Map<ServletContainerInitializer,Set<Class<?>>> initializers =
-        new LinkedHashMap<>();
+    private Map<ServletContainerInitializer, Set<Class<?>>> initializers = new LinkedHashMap<>();
 
 
     /**
      * The set of application parameters defined for this application.
      */
-    private ApplicationParameter applicationParameters[] =
-        new ApplicationParameter[0];
+    private ApplicationParameter applicationParameters[] = new ApplicationParameter[0];
 
     private final Object applicationParametersLock = new Object();
 
@@ -266,8 +257,7 @@ public class StandardContext extends ContainerBase
     /**
      * The Java class name of the CharsetMapper class to be created.
      */
-    private String charsetMapperClass =
-      "org.apache.catalina.util.CharsetMapper";
+    private String charsetMapperClass = "org.apache.catalina.util.CharsetMapper";
 
 
     /**
@@ -285,8 +275,7 @@ public class StandardContext extends ContainerBase
     /**
      * The security constraints for this web application.
      */
-    private volatile SecurityConstraint constraints[] =
-            new SecurityConstraint[0];
+    private volatile SecurityConstraint constraints[] = new SecurityConstraint[0];
 
     private final Object constraintsLock = new Object();
 
@@ -297,9 +286,8 @@ public class StandardContext extends ContainerBase
     protected ApplicationContext context = null;
 
     /**
-     * The wrapped version of the associated ServletContext that is presented
-     * to listeners that are required to have limited access to ServletContext
-     * methods. See Servlet 3.1 section 4.4.
+     * The wrapped version of the associated ServletContext that is presented to listeners that are required to have
+     * limited access to ServletContext methods. See Servlet 3.1 section 4.4.
      */
     private NoPluggabilityServletContext noPluggabilityServletContext = null;
 
@@ -311,8 +299,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Should we allow the <code>ServletContext.getContext()</code> method
-     * to access the context of other web applications in this server?
+     * Should we allow the <code>ServletContext.getContext()</code> method to access the context of other web
+     * applications in this server?
      */
     private boolean crossContext = false;
 
@@ -330,8 +318,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The "follow standard delegation model" flag that will be used to
-     * configure our ClassLoader.
+     * The "follow standard delegation model" flag that will be used to configure our ClassLoader.
      */
     private boolean delegate = false;
 
@@ -373,25 +360,21 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The set of filter configurations (and associated filter instances) we
-     * have initialized, keyed by filter name.
+     * The set of filter configurations (and associated filter instances) we have initialized, keyed by filter name.
      */
-    private HashMap<String, ApplicationFilterConfig> filterConfigs =
-            new HashMap<>();
+    private HashMap<String, ApplicationFilterConfig> filterConfigs = new HashMap<>();
 
 
     /**
-     * The set of filter definitions for this application, keyed by
-     * filter name.
+     * The set of filter definitions for this application, keyed by filter name.
      */
     private HashMap<String, FilterDef> filterDefs = new HashMap<>();
 
 
     /**
-     * The set of filter mappings for this application, in the order
-     * they were defined in the deployment descriptor with additional mappings
-     * added via the {@link ServletContext} possibly both before and after those
-     * defined in the deployment descriptor.
+     * The set of filter mappings for this application, in the order they were defined in the deployment descriptor with
+     * additional mappings added via the {@link ServletContext} possibly both before and after those defined in the
+     * deployment descriptor.
      */
     private final ContextFilterMaps filterMaps = new ContextFilterMaps();
 
@@ -435,8 +418,7 @@ public class StandardContext extends ContainerBase
     /**
      * The message destinations for this web application.
      */
-    private HashMap<String, MessageDestination> messageDestinations =
-        new HashMap<>();
+    private HashMap<String, MessageDestination> messageDestinations = new HashMap<>();
 
 
     /**
@@ -446,8 +428,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The context initialization parameters for this web application,
-     * keyed by name.
+     * The context initialization parameters for this web application, keyed by name.
      */
     private final ConcurrentMap<String, String> parameters = new ConcurrentHashMap<>();
 
@@ -459,9 +440,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The public identifier of the DTD for the web application deployment
-     * descriptor version we are currently parsing.  This is used to support
-     * relaxed validation rules when processing version 2.2 web.xml files.
+     * The public identifier of the DTD for the web application deployment descriptor version we are currently parsing.
+     * This is used to support relaxed validation rules when processing version 2.2 web.xml files.
      */
     private String publicId = null;
 
@@ -503,18 +483,15 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Should the next call to <code>addWelcomeFile()</code> cause replacement
-     * of any existing welcome files?  This will be set before processing the
-     * web application's deployment descriptor, so that application specified
-     * choices <strong>replace</strong>, rather than append to, those defined
-     * in the global descriptor.
+     * Should the next call to <code>addWelcomeFile()</code> cause replacement of any existing welcome files? This will
+     * be set before processing the web application's deployment descriptor, so that application specified choices
+     * <strong>replace</strong>, rather than append to, those defined in the global descriptor.
      */
     private boolean replaceWelcomeFiles = false;
 
 
     /**
-     * The security role mappings for this application, keyed by role
-     * name (as used within the application).
+     * The security role mappings for this application, keyed by role name (as used within the application).
      */
     private HashMap<String, String> roleMappings = new HashMap<>();
 
@@ -528,8 +505,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The servlet mappings for this web application, keyed by
-     * matching pattern.
+     * The servlet mappings for this web application, keyed by matching pattern.
      */
     private HashMap<String, String> servletMappings = new HashMap<>();
 
@@ -548,8 +524,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set flag to true to cause the system.out and system.err to be redirected
-     * to the logger when executing a servlet.
+     * Set flag to true to cause the system.out and system.err to be redirected to the logger when executing a servlet.
      */
     private boolean swallowOutput = false;
 
@@ -577,24 +552,23 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The set of classnames of LifecycleListeners that will be added
-     * to each newly created Wrapper by <code>createWrapper()</code>.
+     * The set of classnames of LifecycleListeners that will be added to each newly created Wrapper by
+     * <code>createWrapper()</code>.
      */
     private String wrapperLifecycles[] = new String[0];
 
     private final Object wrapperLifecyclesLock = new Object();
 
     /**
-     * The set of classnames of ContainerListeners that will be added
-     * to each newly created Wrapper by <code>createWrapper()</code>.
+     * The set of classnames of ContainerListeners that will be added to each newly created Wrapper by
+     * <code>createWrapper()</code>.
      */
     private String wrapperListeners[] = new String[0];
 
     private final Object wrapperListenersLock = new Object();
 
     /**
-     * The pathname to the work directory for this context (relative to
-     * the server's home if not absolute).
+     * The pathname to the work directory for this context (relative to the server's home if not absolute).
      */
     private String workDir = null;
 
@@ -628,13 +602,12 @@ public class StandardContext extends ContainerBase
     /**
      * Name of the engine. If null, the domain is used.
      */
-    private String j2EEApplication="none";
-    private String j2EEServer="none";
+    private String j2EEApplication = "none";
+    private String j2EEServer = "none";
 
 
     /**
-     * Attribute value used to turn on/off XML validation for web.xml and
-     * web-fragment.xml files.
+     * Attribute value used to turn on/off XML validation for web.xml and web-fragment.xml files.
      */
     private boolean webXmlValidation = Globals.STRICT_SERVLET_COMPLIANCE;
 
@@ -658,8 +631,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The name to use for session cookies. <code>null</code> indicates that
-     * the name is controlled by the application.
+     * The name to use for session cookies. <code>null</code> indicates that the name is controlled by the application.
      */
     private String sessionCookieName;
 
@@ -671,91 +643,81 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * The domain to use for session cookies. <code>null</code> indicates that
-     * the domain is controlled by the application.
+     * The domain to use for session cookies. <code>null</code> indicates that the domain is controlled by the
+     * application.
      */
     private String sessionCookieDomain;
 
 
     /**
-     * The path to use for session cookies. <code>null</code> indicates that
-     * the path is controlled by the application.
+     * The path to use for session cookies. <code>null</code> indicates that the path is controlled by the application.
      */
     private String sessionCookiePath;
 
 
     /**
-     * Is a / added to the end of the session cookie path to ensure browsers,
-     * particularly IE, don't send a session cookie for context /foo with
-     * requests intended for context /foobar.
+     * Is a / added to the end of the session cookie path to ensure browsers, particularly IE, don't send a session
+     * cookie for context /foo with requests intended for context /foobar.
      */
     private boolean sessionCookiePathUsesTrailingSlash = false;
 
 
     /**
-     * The Jar scanner to use to search for Jars that might contain
-     * configuration information such as TLDs or web-fragment.xml files.
+     * The Jar scanner to use to search for Jars that might contain configuration information such as TLDs or
+     * web-fragment.xml files.
      */
     private JarScanner jarScanner = null;
 
     /**
-     * Enables the RMI Target memory leak detection to be controlled. This is
-     * necessary since the detection can only work on Java 9 if some of the
-     * modularity checks are disabled.
+     * Enables the RMI Target memory leak detection to be controlled. This is necessary since the detection can only
+     * work on Java 9 if some of the modularity checks are disabled.
      */
     private boolean clearReferencesRmiTargets = true;
 
     /**
-     * Should Tomcat attempt to terminate threads that have been started by the
-     * web application? Stopping threads is performed via the deprecated (for
-     * good reason) <code>Thread.stop()</code> method and is likely to result in
-     * instability. As such, enabling this should be viewed as an option of last
-     * resort in a development environment and is not recommended in a
-     * production environment. If not specified, the default value of
-     * <code>false</code> will be used.
+     * Should Tomcat attempt to terminate threads that have been started by the web application? Stopping threads is
+     * performed via the deprecated (for good reason) <code>Thread.stop()</code> method and is likely to result in
+     * instability. As such, enabling this should be viewed as an option of last resort in a development environment and
+     * is not recommended in a production environment. If not specified, the default value of <code>false</code> will be
+     * used.
      */
     private boolean clearReferencesStopThreads = false;
 
     /**
-     * Should Tomcat attempt to terminate any {@link java.util.TimerThread}s
-     * that have been started by the web application? If not specified, the
-     * default value of <code>false</code> will be used.
+     * Should Tomcat attempt to terminate any {@link java.util.TimerThread}s that have been started by the web
+     * application? If not specified, the default value of <code>false</code> will be used.
      */
     private boolean clearReferencesStopTimerThreads = false;
 
     /**
-     * If an HttpClient keep-alive timer thread has been started by this web
-     * application and is still running, should Tomcat change the context class
-     * loader from the current {@link ClassLoader} to
-     * {@link ClassLoader#getParent()} to prevent a memory leak? Note that the
-     * keep-alive timer thread will stop on its own once the keep-alives all
-     * expire however, on a busy system that might not happen for some time.
+     * If an HttpClient keep-alive timer thread has been started by this web application and is still running, should
+     * Tomcat change the context class loader from the current {@link ClassLoader} to {@link ClassLoader#getParent()} to
+     * prevent a memory leak? Note that the keep-alive timer thread will stop on its own once the keep-alives all expire
+     * however, on a busy system that might not happen for some time.
      */
     private boolean clearReferencesHttpClientKeepAliveThread = true;
 
     /**
-     * Should Tomcat renew the threads of the thread pool when the application
-     * is stopped to avoid memory leaks because of uncleaned ThreadLocal
-     * variables. This also requires that the threadRenewalDelay property of the
+     * Should Tomcat renew the threads of the thread pool when the application is stopped to avoid memory leaks because
+     * of uncleaned ThreadLocal variables. This also requires that the threadRenewalDelay property of the
      * StandardThreadExecutor or ThreadPoolExecutor be set to a positive value.
      */
     private boolean renewThreadsWhenStoppingContext = true;
 
     /**
-     * Should Tomcat attempt to clear references to classes loaded by the web
-     * application class loader from the ObjectStreamClass caches?
+     * Should Tomcat attempt to clear references to classes loaded by the web application class loader from the
+     * ObjectStreamClass caches?
      */
     private boolean clearReferencesObjectStreamClassCaches = true;
 
     /**
-     * Should Tomcat attempt to clear references to classes loaded by this class
-     * loader from ThreadLocals?
+     * Should Tomcat attempt to clear references to classes loaded by this class loader from ThreadLocals?
      */
     private boolean clearReferencesThreadLocals = true;
 
     /**
-     * Should Tomcat skip the memory leak checks when the web application is
-     * stopped as part of the process of shutting down the JVM?
+     * Should Tomcat skip the memory leak checks when the web application is stopped as part of the process of shutting
+     * down the JVM?
      */
     private boolean skipMemoryLeakChecksOnJvmShutdown = false;
 
@@ -779,8 +741,7 @@ public class StandardContext extends ContainerBase
     private boolean fireRequestListenersOnForwards = false;
 
     /**
-     * Servlets created via {@link ApplicationContext#createServlet(Class)} for
-     * tracking purposes.
+     * Servlets created via {@link ApplicationContext#createServlet(Class)} for tracking purposes.
      */
     private Set<Servlet> createdServlets = new HashSet<>();
 
@@ -799,9 +760,12 @@ public class StandardContext extends ContainerBase
 
     protected static final ThreadBindingListener DEFAULT_NAMING_LISTENER = (new ThreadBindingListener() {
         @Override
-        public void bind() {}
+        public void bind() {
+        }
+
         @Override
-        public void unbind() {}
+        public void unbind() {
+        }
     });
     protected ThreadBindingListener threadBindingListener = DEFAULT_NAMING_LISTENER;
 
@@ -862,8 +826,7 @@ public class StandardContext extends ContainerBase
 
 
     @Override
-    public void setAllowMultipleLeadingForwardSlashInPath(
-            boolean allowMultipleLeadingForwardSlashInPath) {
+    public void setAllowMultipleLeadingForwardSlashInPath(boolean allowMultipleLeadingForwardSlashInPath) {
         this.allowMultipleLeadingForwardSlashInPath = allowMultipleLeadingForwardSlashInPath;
     }
 
@@ -895,10 +858,9 @@ public class StandardContext extends ContainerBase
     @Override
     public void setResponseCharacterEncoding(String responseEncoding) {
         /*
-         * This ensures that the context response encoding is represented by a
-         * unique String object. This enables the Default Servlet to
-         * differentiate between a Response using this default encoding and one
-         * that has been explicitly configured.
+         * This ensures that the context response encoding is represented by a unique String object. This enables the
+         * Default Servlet to differentiate between a Response using this default encoding and one that has been
+         * explicitly configured.
          */
         if (responseEncoding == null) {
             this.responseEncoding = null;
@@ -996,8 +958,7 @@ public class StandardContext extends ContainerBase
     @Override
     public void setCookieProcessor(CookieProcessor cookieProcessor) {
         if (cookieProcessor == null) {
-            throw new IllegalArgumentException(
-                    sm.getString("standardContext.cookieProcessor.null"));
+            throw new IllegalArgumentException(sm.getString("standardContext.cookieProcessor.null"));
         }
         this.cookieProcessor = cookieProcessor;
     }
@@ -1064,8 +1025,7 @@ public class StandardContext extends ContainerBase
 
 
     @Override
-    public void setAddWebinfClassesResources(
-            boolean addWebinfClassesResources) {
+    public void setAddWebinfClassesResources(boolean addWebinfClassesResources) {
         this.addWebinfClassesResources = addWebinfClassesResources;
     }
 
@@ -1112,7 +1072,7 @@ public class StandardContext extends ContainerBase
         }
         for (String servletName : resourceOnlyServlets.split(",")) {
             servletName = servletName.trim();
-            if (servletName.length()>0) {
+            if (servletName.length() > 0) {
                 this.resourceOnlyServlets.add(servletName);
             }
         }
@@ -1189,13 +1149,13 @@ public class StandardContext extends ContainerBase
 
     @Override
     public InstanceManager getInstanceManager() {
-       return instanceManager;
+        return instanceManager;
     }
 
 
     @Override
     public void setInstanceManager(InstanceManager instanceManager) {
-       this.instanceManager = instanceManager;
+        this.instanceManager = instanceManager;
     }
 
 
@@ -1206,27 +1166,22 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set to <code>true</code> to allow requests mapped to servlets that
-     * do not explicitly declare @MultipartConfig or have
-     * &lt;multipart-config&gt; specified in web.xml to parse
-     * multipart/form-data requests.
+     * Set to <code>true</code> to allow requests mapped to servlets that do not explicitly declare @MultipartConfig or
+     * have &lt;multipart-config&gt; specified in web.xml to parse multipart/form-data requests.
      *
-     * @param allowCasualMultipartParsing <code>true</code> to allow such
-     *        casual parsing, <code>false</code> otherwise.
+     * @param allowCasualMultipartParsing <code>true</code> to allow such casual parsing, <code>false</code> otherwise.
      */
     @Override
-    public void setAllowCasualMultipartParsing(
-            boolean allowCasualMultipartParsing) {
+    public void setAllowCasualMultipartParsing(boolean allowCasualMultipartParsing) {
         this.allowCasualMultipartParsing = allowCasualMultipartParsing;
     }
 
     /**
-     * Returns <code>true</code> if requests mapped to servlets without
-     * "multipart config" to parse multipart/form-data requests anyway.
+     * Returns <code>true</code> if requests mapped to servlets without "multipart config" to parse multipart/form-data
+     * requests anyway.
      *
-     * @return <code>true</code> if requests mapped to servlets without
-     *    "multipart config" to parse multipart/form-data requests,
-     *    <code>false</code> otherwise.
+     * @return <code>true</code> if requests mapped to servlets without "multipart config" to parse multipart/form-data
+     *             requests, <code>false</code> otherwise.
      */
     @Override
     public boolean getAllowCasualMultipartParsing() {
@@ -1234,11 +1189,9 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Set to <code>false</code> to disable request data swallowing
-     * after an upload was aborted due to size constraints.
+     * Set to <code>false</code> to disable request data swallowing after an upload was aborted due to size constraints.
      *
-     * @param swallowAbortedUploads <code>false</code> to disable
-     *        swallowing, <code>true</code> otherwise (default).
+     * @param swallowAbortedUploads <code>false</code> to disable swallowing, <code>true</code> otherwise (default).
      */
     @Override
     public void setSwallowAbortedUploads(boolean swallowAbortedUploads) {
@@ -1246,11 +1199,10 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Returns <code>true</code> if remaining request data will be read
-     * (swallowed) even the request violates a data size constraint.
+     * Returns <code>true</code> if remaining request data will be read (swallowed) even the request violates a data
+     * size constraint.
      *
-     * @return <code>true</code> if data will be swallowed (default),
-     *    <code>false</code> otherwise.
+     * @return <code>true</code> if data will be swallowed (default), <code>false</code> otherwise.
      */
     @Override
     public boolean getSwallowAbortedUploads() {
@@ -1260,20 +1212,17 @@ public class StandardContext extends ContainerBase
     /**
      * Add a ServletContainerInitializer instance to this web application.
      *
-     * @param sci       The instance to add
-     * @param classes   The classes in which the initializer expressed an
-     *                  interest
+     * @param sci     The instance to add
+     * @param classes The classes in which the initializer expressed an interest
      */
     @Override
-    public void addServletContainerInitializer(
-            ServletContainerInitializer sci, Set<Class<?>> classes) {
+    public void addServletContainerInitializer(ServletContainerInitializer sci, Set<Class<?>> classes) {
         initializers.put(sci, classes);
     }
 
 
     /**
-     * Return the "follow standard delegation model" flag used to configure
-     * our ClassLoader.
+     * Return the "follow standard delegation model" flag used to configure our ClassLoader.
      *
      * @return <code>true</code> if classloading delegates to the parent classloader first
      */
@@ -1283,8 +1232,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the "follow standard delegation model" flag used to configure
-     * our ClassLoader.
+     * Set the "follow standard delegation model" flag used to configure our ClassLoader.
      *
      * @param delegate The new flag
      */
@@ -1292,8 +1240,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldDelegate = this.delegate;
         this.delegate = delegate;
-        support.firePropertyChange("delegate", oldDelegate,
-                                   this.delegate);
+        support.firePropertyChange("delegate", oldDelegate, this.delegate);
 
     }
 
@@ -1323,11 +1270,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * {@inheritDoc}
-     *
-     * Note that this implementation is not thread safe. If two threads call
-     * this method concurrently, the result may be either set of listeners or a
-     * the union of both.
+     * {@inheritDoc} Note that this implementation is not thread safe. If two threads call this method concurrently, the
+     * result may be either set of listeners or a the union of both.
      */
     @Override
     public void setApplicationEventListeners(Object listeners[]) {
@@ -1339,8 +1283,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Add a listener to the end of the list of initialized application event
-     * listeners.
+     * Add a listener to the end of the list of initialized application event listeners.
      *
      * @param listener The listener to add
      */
@@ -1356,9 +1299,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Store the set of initialized application lifecycle listener objects,
-     * in the order they were specified in the web application deployment
-     * descriptor, for this application.
+     * Store the set of initialized application lifecycle listener objects, in the order they were specified in the web
+     * application deployment descriptor, for this application.
      *
      * @param listeners The set of instantiated listener objects.
      */
@@ -1369,15 +1311,13 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Add a listener to the end of the list of initialized application
-     * lifecycle listeners.
+     * Add a listener to the end of the list of initialized application lifecycle listeners.
      *
      * @param listener The listener to add
      */
     public void addApplicationLifecycleListener(Object listener) {
         int len = applicationLifecycleListenersObjects.length;
-        Object[] newListeners = Arrays.copyOf(
-                applicationLifecycleListenersObjects, len + 1);
+        Object[] newListeners = Arrays.copyOf(applicationLifecycleListenersObjects, len + 1);
         newListeners[len] = listener;
         applicationLifecycleListenersObjects = newListeners;
     }
@@ -1400,9 +1340,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldAntiResourceLocking = this.antiResourceLocking;
         this.antiResourceLocking = antiResourceLocking;
-        support.firePropertyChange("antiResourceLocking",
-                                   oldAntiResourceLocking,
-                                   this.antiResourceLocking);
+        support.firePropertyChange("antiResourceLocking", oldAntiResourceLocking, this.antiResourceLocking);
 
     }
 
@@ -1437,11 +1375,10 @@ public class StandardContext extends ContainerBase
 
         CharsetMapper oldCharsetMapper = this.charsetMapper;
         this.charsetMapper = mapper;
-        if( mapper != null ) {
-            this.charsetMapperClass= mapper.getClass().getName();
+        if (mapper != null) {
+            this.charsetMapperClass = mapper.getClass().getName();
         }
-        support.firePropertyChange("charsetMapper", oldCharsetMapper,
-                                   this.charsetMapper);
+        support.firePropertyChange("charsetMapper", oldCharsetMapper, this.charsetMapper);
 
     }
 
@@ -1471,9 +1408,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the "correctly configured" flag for this Context.  This can be
-     * set to false by startup listeners that detect a fatal configuration
-     * error to avoid the application from being made available.
+     * Set the "correctly configured" flag for this Context. This can be set to false by startup listeners that detect a
+     * fatal configuration error to avoid the application from being made available.
      *
      * @param configured The new correctly configured flag
      */
@@ -1482,9 +1418,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldConfigured = this.configured;
         this.configured = configured;
-        support.firePropertyChange("configured",
-                                   oldConfigured,
-                                   this.configured);
+        support.firePropertyChange("configured", oldConfigured, this.configured);
 
     }
 
@@ -1505,19 +1439,15 @@ public class StandardContext extends ContainerBase
 
         boolean oldCookies = this.cookies;
         this.cookies = cookies;
-        support.firePropertyChange("cookies",
-                                   oldCookies,
-                                   this.cookies);
+        support.firePropertyChange("cookies", oldCookies, this.cookies);
 
     }
 
 
     /**
-     * Gets the name to use for session cookies. Overrides any setting that
-     * may be specified by the application.
+     * Gets the name to use for session cookies. Overrides any setting that may be specified by the application.
      *
-     * @return  The value of the default session cookie name or null if not
-     *          specified
+     * @return The value of the default session cookie name or null if not specified
      */
     @Override
     public String getSessionCookieName() {
@@ -1526,25 +1456,22 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Sets the name to use for session cookies. Overrides any setting that
-     * may be specified by the application.
+     * Sets the name to use for session cookies. Overrides any setting that may be specified by the application.
      *
-     * @param sessionCookieName   The name to use
+     * @param sessionCookieName The name to use
      */
     @Override
     public void setSessionCookieName(String sessionCookieName) {
         String oldSessionCookieName = this.sessionCookieName;
         this.sessionCookieName = sessionCookieName;
-        support.firePropertyChange("sessionCookieName",
-                oldSessionCookieName, sessionCookieName);
+        support.firePropertyChange("sessionCookieName", oldSessionCookieName, sessionCookieName);
     }
 
 
     /**
      * Gets the value of the use HttpOnly cookies for session cookies flag.
      *
-     * @return <code>true</code> if the HttpOnly flag should be set on session
-     *         cookies
+     * @return <code>true</code> if the HttpOnly flag should be set on session cookies
      */
     @Override
     public boolean getUseHttpOnly() {
@@ -1555,25 +1482,20 @@ public class StandardContext extends ContainerBase
     /**
      * Sets the use HttpOnly cookies for session cookies flag.
      *
-     * @param useHttpOnly   Set to <code>true</code> to use HttpOnly cookies
-     *                          for session cookies
+     * @param useHttpOnly Set to <code>true</code> to use HttpOnly cookies for session cookies
      */
     @Override
     public void setUseHttpOnly(boolean useHttpOnly) {
         boolean oldUseHttpOnly = this.useHttpOnly;
         this.useHttpOnly = useHttpOnly;
-        support.firePropertyChange("useHttpOnly",
-                oldUseHttpOnly,
-                this.useHttpOnly);
+        support.firePropertyChange("useHttpOnly", oldUseHttpOnly, this.useHttpOnly);
     }
 
 
     /**
-     * Gets the domain to use for session cookies. Overrides any setting that
-     * may be specified by the application.
+     * Gets the domain to use for session cookies. Overrides any setting that may be specified by the application.
      *
-     * @return  The value of the default session cookie domain or null if not
-     *          specified
+     * @return The value of the default session cookie domain or null if not specified
      */
     @Override
     public String getSessionCookieDomain() {
@@ -1582,26 +1504,22 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Sets the domain to use for session cookies. Overrides any setting that
-     * may be specified by the application.
+     * Sets the domain to use for session cookies. Overrides any setting that may be specified by the application.
      *
-     * @param sessionCookieDomain   The domain to use
+     * @param sessionCookieDomain The domain to use
      */
     @Override
     public void setSessionCookieDomain(String sessionCookieDomain) {
         String oldSessionCookieDomain = this.sessionCookieDomain;
         this.sessionCookieDomain = sessionCookieDomain;
-        support.firePropertyChange("sessionCookieDomain",
-                oldSessionCookieDomain, sessionCookieDomain);
+        support.firePropertyChange("sessionCookieDomain", oldSessionCookieDomain, sessionCookieDomain);
     }
 
 
     /**
-     * Gets the path to use for session cookies. Overrides any setting that
-     * may be specified by the application.
+     * Gets the path to use for session cookies. Overrides any setting that may be specified by the application.
      *
-     * @return  The value of the default session cookie path or null if not
-     *          specified
+     * @return The value of the default session cookie path or null if not specified
      */
     @Override
     public String getSessionCookiePath() {
@@ -1610,17 +1528,15 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Sets the path to use for session cookies. Overrides any setting that
-     * may be specified by the application.
+     * Sets the path to use for session cookies. Overrides any setting that may be specified by the application.
      *
-     * @param sessionCookiePath   The path to use
+     * @param sessionCookiePath The path to use
      */
     @Override
     public void setSessionCookiePath(String sessionCookiePath) {
         String oldSessionCookiePath = this.sessionCookiePath;
         this.sessionCookiePath = sessionCookiePath;
-        support.firePropertyChange("sessionCookiePath",
-                oldSessionCookiePath, sessionCookiePath);
+        support.firePropertyChange("sessionCookiePath", oldSessionCookiePath, sessionCookiePath);
     }
 
 
@@ -1631,10 +1547,8 @@ public class StandardContext extends ContainerBase
 
 
     @Override
-    public void setSessionCookiePathUsesTrailingSlash(
-            boolean sessionCookiePathUsesTrailingSlash) {
-        this.sessionCookiePathUsesTrailingSlash =
-            sessionCookiePathUsesTrailingSlash;
+    public void setSessionCookiePathUsesTrailingSlash(boolean sessionCookiePathUsesTrailingSlash) {
+        this.sessionCookiePathUsesTrailingSlash = sessionCookiePathUsesTrailingSlash;
     }
 
 
@@ -1654,9 +1568,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldCrossContext = this.crossContext;
         this.crossContext = crossContext;
-        support.firePropertyChange("crossContext",
-                                   oldCrossContext,
-                                   this.crossContext);
+        support.firePropertyChange("crossContext", oldCrossContext, this.crossContext);
 
     }
 
@@ -1665,9 +1577,8 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Set the location of the default context xml that will be used.
-     * If not absolute, it'll be made relative to the engine's base dir
-     * ( which defaults to catalina.base system property ).
+     * Set the location of the default context xml that will be used. If not absolute, it'll be made relative to the
+     * engine's base dir ( which defaults to catalina.base system property ).
      *
      * @param defaultContextXml The default web xml
      */
@@ -1680,9 +1591,8 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Set the location of the default web xml that will be used.
-     * If not absolute, it'll be made relative to the engine's base dir
-     * ( which defaults to catalina.base system property ).
+     * Set the location of the default web xml that will be used. If not absolute, it'll be made relative to the
+     * engine's base dir ( which defaults to catalina.base system property ).
      *
      * @param defaultWebXml The default web xml
      */
@@ -1737,7 +1647,7 @@ public class StandardContext extends ContainerBase
      * @return the alternate Deployment Descriptor name.
      */
     @Override
-    public String getAltDDName(){
+    public String getAltDDName() {
         return altDDName;
     }
 
@@ -1751,7 +1661,7 @@ public class StandardContext extends ContainerBase
     public void setAltDDName(String altDDName) {
         this.altDDName = altDDName;
         if (context != null) {
-            context.setAttribute(Globals.ALT_DD_ATTR,altDDName);
+            context.setAttribute(Globals.ALT_DD_ATTR, altDDName);
         }
     }
 
@@ -1766,8 +1676,7 @@ public class StandardContext extends ContainerBase
 
         String oldDisplayName = this.displayName;
         this.displayName = displayName;
-        support.firePropertyChange("displayName", oldDisplayName,
-                                   this.displayName);
+        support.firePropertyChange("displayName", oldDisplayName, this.displayName);
     }
 
 
@@ -1788,9 +1697,7 @@ public class StandardContext extends ContainerBase
     public void setDistributable(boolean distributable) {
         boolean oldDistributable = this.distributable;
         this.distributable = distributable;
-        support.firePropertyChange("distributable",
-                                   oldDistributable,
-                                   this.distributable);
+        support.firePropertyChange("distributable", oldDistributable, this.distributable);
     }
 
 
@@ -1849,8 +1756,7 @@ public class StandardContext extends ContainerBase
             this.loader = loader;
 
             // Stop the old component if necessary
-            if (getState().isAvailable() && (oldLoader != null) &&
-                (oldLoader instanceof Lifecycle)) {
+            if (getState().isAvailable() && (oldLoader != null) && (oldLoader instanceof Lifecycle)) {
                 try {
                     ((Lifecycle) oldLoader).stop();
                 } catch (LifecycleException e) {
@@ -1862,8 +1768,7 @@ public class StandardContext extends ContainerBase
             if (loader != null) {
                 loader.setContext(this);
             }
-            if (getState().isAvailable() && (loader != null) &&
-                (loader instanceof Lifecycle)) {
+            if (getState().isAvailable() && (loader != null) && (loader instanceof Lifecycle)) {
                 try {
                     ((Lifecycle) loader).start();
                 } catch (LifecycleException e) {
@@ -1945,8 +1850,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the boolean on the annotations parsing for this web
-     * application.
+     * Set the boolean on the annotations parsing for this web application.
      *
      * @param ignoreAnnotations The boolean on the annotations parsing
      */
@@ -1954,8 +1858,7 @@ public class StandardContext extends ContainerBase
     public void setIgnoreAnnotations(boolean ignoreAnnotations) {
         boolean oldIgnoreAnnotations = this.ignoreAnnotations;
         this.ignoreAnnotations = ignoreAnnotations;
-        support.firePropertyChange("ignoreAnnotations", oldIgnoreAnnotations,
-                this.ignoreAnnotations);
+        support.firePropertyChange("ignoreAnnotations", oldIgnoreAnnotations, this.ignoreAnnotations);
     }
 
 
@@ -1978,43 +1881,35 @@ public class StandardContext extends ContainerBase
 
         // Validate the incoming property value
         if (config == null) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.loginConfig.required"));
+            throw new IllegalArgumentException(sm.getString("standardContext.loginConfig.required"));
         }
         String loginPage = config.getLoginPage();
         if ((loginPage != null) && !loginPage.startsWith("/")) {
             if (isServlet22()) {
-                if(log.isDebugEnabled()) {
-                    log.debug(sm.getString("standardContext.loginConfig.loginWarning",
-                                 loginPage));
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("standardContext.loginConfig.loginWarning", loginPage));
                 }
                 config.setLoginPage("/" + loginPage);
             } else {
-                throw new IllegalArgumentException
-                    (sm.getString("standardContext.loginConfig.loginPage",
-                                  loginPage));
+                throw new IllegalArgumentException(sm.getString("standardContext.loginConfig.loginPage", loginPage));
             }
         }
         String errorPage = config.getErrorPage();
         if ((errorPage != null) && !errorPage.startsWith("/")) {
             if (isServlet22()) {
-                if(log.isDebugEnabled()) {
-                    log.debug(sm.getString("standardContext.loginConfig.errorWarning",
-                                 errorPage));
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("standardContext.loginConfig.errorWarning", errorPage));
                 }
                 config.setErrorPage("/" + errorPage);
             } else {
-                throw new IllegalArgumentException
-                    (sm.getString("standardContext.loginConfig.errorPage",
-                                  errorPage));
+                throw new IllegalArgumentException(sm.getString("standardContext.loginConfig.errorPage", errorPage));
             }
         }
 
         // Process the property setting change
         LoginConfig oldLoginConfig = this.loginConfig;
         this.loginConfig = config;
-        support.firePropertyChange("loginConfig",
-                                   oldLoginConfig, this.loginConfig);
+        support.firePropertyChange("loginConfig", oldLoginConfig, this.loginConfig);
 
     }
 
@@ -2045,11 +1940,9 @@ public class StandardContext extends ContainerBase
         if (namingResources != null) {
             namingResources.setContainer(this);
         }
-        support.firePropertyChange("namingResources",
-                                   oldNamingResources, this.namingResources);
+        support.firePropertyChange("namingResources", oldNamingResources, this.namingResources);
 
-        if (getState() == LifecycleState.NEW ||
-                getState() == LifecycleState.INITIALIZING ||
+        if (getState() == LifecycleState.NEW || getState() == LifecycleState.INITIALIZING ||
                 getState() == LifecycleState.INITIALIZED) {
             // NEW will occur if Context is defined in server.xml
             // At this point getObjectKeyPropertiesNameOnly() will trigger an
@@ -2114,8 +2007,7 @@ public class StandardContext extends ContainerBase
             this.path = this.path.substring(0, this.path.length() - 1);
         }
         if (invalid) {
-            log.warn(sm.getString(
-                    "standardContext.pathInvalid", path, this.path));
+            log.warn(sm.getString("standardContext.pathInvalid", path, this.path));
         }
         encodedPath = URLEncoder.DEFAULT.encode(this.path, StandardCharsets.UTF_8);
         if (getName() == null) {
@@ -2125,8 +2017,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the public identifier of the deployment descriptor DTD that is
-     * currently being parsed.
+     * @return the public identifier of the deployment descriptor DTD that is currently being parsed.
      */
     @Override
     public String getPublicId() {
@@ -2135,8 +2026,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the public identifier of the deployment descriptor DTD that is
-     * currently being parsed.
+     * Set the public identifier of the deployment descriptor DTD that is currently being parsed.
      *
      * @param publicId The public identifier
      */
@@ -2144,8 +2034,7 @@ public class StandardContext extends ContainerBase
     public void setPublicId(String publicId) {
 
         if (log.isDebugEnabled()) {
-            log.debug("Setting deployment descriptor public ID to '" +
-                publicId + "'");
+            log.debug("Setting deployment descriptor public ID to '" + publicId + "'");
         }
 
         String oldPublicId = this.publicId;
@@ -2174,17 +2063,15 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the original document root for this Context.  This can be an absolute
-     * pathname, a relative pathname, or a URL.
-     * Is only set as deployment has change docRoot!
+     * @return the original document root for this Context. This can be an absolute pathname, a relative pathname, or a
+     *             URL. Is only set as deployment has change docRoot!
      */
     public String getOriginalDocBase() {
         return this.originalDocBase;
     }
 
     /**
-     * Set the original document root for this Context.  This can be an absolute
-     * pathname, a relative pathname, or a URL.
+     * Set the original document root for this Context. This can be an absolute pathname, a relative pathname, or a URL.
      *
      * @param docBase The original document root
      */
@@ -2195,9 +2082,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the parent class loader (if any) for this web application.
-     * This call is meaningful only <strong>after</strong> a Loader has
-     * been configured.
+     * @return the parent class loader (if any) for this web application. This call is meaningful only
+     *             <strong>after</strong> a Loader has been configured.
      */
     @Override
     public ClassLoader getParentClassLoader() {
@@ -2232,9 +2118,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldPrivileged = this.privileged;
         this.privileged = privileged;
-        support.firePropertyChange("privileged",
-                                   oldPrivileged,
-                                   this.privileged);
+        support.firePropertyChange("privileged", oldPrivileged, this.privileged);
 
     }
 
@@ -2249,9 +2133,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldReloadable = this.reloadable;
         this.reloadable = reloadable;
-        support.firePropertyChange("reloadable",
-                                   oldReloadable,
-                                   this.reloadable);
+        support.firePropertyChange("reloadable", oldReloadable, this.reloadable);
 
     }
 
@@ -2266,9 +2148,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldOverride = this.override;
         this.override = override;
-        support.firePropertyChange("override",
-                                   oldOverride,
-                                   this.override);
+        support.firePropertyChange("override", oldOverride, this.override);
 
     }
 
@@ -2282,9 +2162,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldReplaceWelcomeFiles = this.replaceWelcomeFiles;
         this.replaceWelcomeFiles = replaceWelcomeFiles;
-        support.firePropertyChange("replaceWelcomeFiles",
-                                   oldReplaceWelcomeFiles,
-                                   this.replaceWelcomeFiles);
+        support.firePropertyChange("replaceWelcomeFiles", oldReplaceWelcomeFiles, this.replaceWelcomeFiles);
 
     }
 
@@ -2297,7 +2175,7 @@ public class StandardContext extends ContainerBase
         if (context == null) {
             context = new ApplicationContext(this);
             if (altDDName != null) {
-                context.setAttribute(Globals.ALT_DD_ATTR,altDDName);
+                context.setAttribute(Globals.ALT_DD_ATTR, altDDName);
             }
         }
         return context.getFacade();
@@ -2305,8 +2183,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the default session timeout (in minutes) for this
-     * web application.
+     * @return the default session timeout (in minutes) for this web application.
      */
     @Override
     public int getSessionTimeout() {
@@ -2315,8 +2192,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the default session timeout (in minutes) for this
-     * web application.
+     * Set the default session timeout (in minutes) for this web application.
      *
      * @param timeout The new default session timeout
      */
@@ -2325,14 +2201,11 @@ public class StandardContext extends ContainerBase
 
         int oldSessionTimeout = this.sessionTimeout;
         /*
-         * SRV.13.4 ("Deployment Descriptor"):
-         * If the timeout is 0 or less, the container ensures the default
-         * behaviour of sessions is never to time out.
+         * SRV.13.4 ("Deployment Descriptor"): If the timeout is 0 or less, the container ensures the default behaviour
+         * of sessions is never to time out.
          */
         this.sessionTimeout = (timeout == 0) ? -1 : timeout;
-        support.firePropertyChange("sessionTimeout",
-                                   oldSessionTimeout,
-                                   this.sessionTimeout);
+        support.firePropertyChange("sessionTimeout", oldSessionTimeout, this.sessionTimeout);
 
     }
 
@@ -2347,9 +2220,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the value of the swallowOutput flag. If set to true, the system.out
-     * and system.err will be redirected to the logger during a servlet
-     * execution.
+     * Set the value of the swallowOutput flag. If set to true, the system.out and system.err will be redirected to the
+     * logger during a servlet execution.
      *
      * @param swallowOutput The new value
      */
@@ -2358,9 +2230,7 @@ public class StandardContext extends ContainerBase
 
         boolean oldSwallowOutput = this.swallowOutput;
         this.swallowOutput = swallowOutput;
-        support.firePropertyChange("swallowOutput",
-                                   oldSwallowOutput,
-                                   this.swallowOutput);
+        support.firePropertyChange("swallowOutput", oldSwallowOutput, this.swallowOutput);
 
     }
 
@@ -2374,10 +2244,9 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the value of the unloadDelay flag, which represents the amount
-     * of ms that the container will wait when unloading servlets.
-     * Setting this to a small value may cause more requests to fail
-     * to complete when stopping a web application.
+     * Set the value of the unloadDelay flag, which represents the amount of ms that the container will wait when
+     * unloading servlets. Setting this to a small value may cause more requests to fail to complete when stopping a web
+     * application.
      *
      * @param unloadDelay The new value
      */
@@ -2385,9 +2254,7 @@ public class StandardContext extends ContainerBase
 
         long oldUnloadDelay = this.unloadDelay;
         this.unloadDelay = unloadDelay;
-        support.firePropertyChange("unloadDelay",
-                                   Long.valueOf(oldUnloadDelay),
-                                   Long.valueOf(this.unloadDelay));
+        support.firePropertyChange("unloadDelay", Long.valueOf(oldUnloadDelay), Long.valueOf(this.unloadDelay));
 
     }
 
@@ -2411,11 +2278,11 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Flag which indicates if bundled context.xml files should be copied to the
-     * config folder. The doesn't occur by default.
+     * Flag which indicates if bundled context.xml files should be copied to the config folder. The doesn't occur by
+     * default.
      *
-     * @return <code>true</code> if the <code>META-INF/context.xml</code> file included
-     *     in a WAR will be copied to the host configuration base folder on deployment
+     * @return <code>true</code> if the <code>META-INF/context.xml</code> file included in a WAR will be copied to the
+     *             host configuration base folder on deployment
      */
     public boolean getCopyXML() {
         return copyXML;
@@ -2423,8 +2290,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Allows copying a bundled context.xml file to the host configuration base
-     * folder on deployment.
+     * Allows copying a bundled context.xml file to the host configuration base folder on deployment.
      *
      * @param copyXML the new flag value
      */
@@ -2434,8 +2300,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the Java class name of the Wrapper implementation used
-     * for servlets registered in this Context.
+     * @return the Java class name of the Wrapper implementation used for servlets registered in this Context.
      */
     @Override
     public String getWrapperClass() {
@@ -2444,13 +2309,12 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the Java class name of the Wrapper implementation used
-     * for servlets registered in this Context.
+     * Set the Java class name of the Wrapper implementation used for servlets registered in this Context.
      *
      * @param wrapperClassName The new wrapper class name
      *
-     * @throws IllegalArgumentException if the specified wrapper class
-     * cannot be found or is not a subclass of StandardWrapper
+     * @throws IllegalArgumentException if the specified wrapper class cannot be found or is not a subclass of
+     *                                      StandardWrapper
      */
     @Override
     public void setWrapperClass(String wrapperClassName) {
@@ -2461,8 +2325,7 @@ public class StandardContext extends ContainerBase
             wrapperClass = Class.forName(wrapperClassName);
             if (!StandardWrapper.class.isAssignableFrom(wrapperClass)) {
                 throw new IllegalArgumentException(
-                    sm.getString("standardContext.invalidWrapperClass",
-                                 wrapperClassName));
+                        sm.getString("standardContext.invalidWrapperClass", wrapperClassName));
             }
         } catch (ClassNotFoundException cnfe) {
             throw new IllegalArgumentException(cnfe.getMessage());
@@ -2490,8 +2353,7 @@ public class StandardContext extends ContainerBase
         WebResourceRoot oldResources = null;
         try {
             if (getState().isAvailable()) {
-                throw new IllegalStateException
-                    (sm.getString("standardContext.resourcesStart"));
+                throw new IllegalStateException(sm.getString("standardContext.resourcesStart"));
             }
 
             oldResources = this.resources;
@@ -2507,8 +2369,7 @@ public class StandardContext extends ContainerBase
                 resources.setContext(this);
             }
 
-            support.firePropertyChange("resources", oldResources,
-                    resources);
+            support.firePropertyChange("resources", oldResources, resources);
         } finally {
             writeLock.unlock();
         }
@@ -2539,8 +2400,8 @@ public class StandardContext extends ContainerBase
     // ------------------------------------------------------ Public Properties
 
     /**
-     * @return whether or not an attempt to modify the JNDI context will trigger
-     * an exception or if the request will be ignored.
+     * @return whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be
+     *             ignored.
      */
     public boolean getJndiExceptionOnFailedWrite() {
         return jndiExceptionOnFailedWrite;
@@ -2548,13 +2409,12 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Controls whether or not an attempt to modify the JNDI context will
-     * trigger an exception or if the request will be ignored.
+     * Controls whether or not an attempt to modify the JNDI context will trigger an exception or if the request will be
+     * ignored.
      *
      * @param jndiExceptionOnFailedWrite <code>false</code> to avoid an exception
      */
-    public void setJndiExceptionOnFailedWrite(
-            boolean jndiExceptionOnFailedWrite) {
+    public void setJndiExceptionOnFailedWrite(boolean jndiExceptionOnFailedWrite) {
         this.jndiExceptionOnFailedWrite = jndiExceptionOnFailedWrite;
     }
 
@@ -2576,9 +2436,7 @@ public class StandardContext extends ContainerBase
 
         String oldCharsetMapperClass = this.charsetMapperClass;
         this.charsetMapperClass = mapper;
-        support.firePropertyChange("charsetMapperClass",
-                                   oldCharsetMapperClass,
-                                   this.charsetMapperClass);
+        support.firePropertyChange("charsetMapperClass", oldCharsetMapperClass, this.charsetMapperClass);
 
     }
 
@@ -2595,11 +2453,9 @@ public class StandardContext extends ContainerBase
         File workDir = new File(getWorkDir());
         if (!workDir.isAbsolute()) {
             try {
-                workDir = new File(getCatalinaBase().getCanonicalFile(),
-                        getWorkDir());
+                workDir = new File(getCatalinaBase().getCanonicalFile(), getWorkDir());
             } catch (IOException e) {
-                log.warn(sm.getString("standardContext.workPath", getName()),
-                        e);
+                log.warn(sm.getString("standardContext.workPath", getName()), e);
             }
         }
         return workDir.getAbsolutePath();
@@ -2636,8 +2492,8 @@ public class StandardContext extends ContainerBase
     public void setClearReferencesRmiTargets(boolean clearReferencesRmiTargets) {
         boolean oldClearReferencesRmiTargets = this.clearReferencesRmiTargets;
         this.clearReferencesRmiTargets = clearReferencesRmiTargets;
-        support.firePropertyChange("clearReferencesRmiTargets",
-                oldClearReferencesRmiTargets, this.clearReferencesRmiTargets);
+        support.firePropertyChange("clearReferencesRmiTargets", oldClearReferencesRmiTargets,
+                this.clearReferencesRmiTargets);
     }
 
 
@@ -2654,14 +2510,12 @@ public class StandardContext extends ContainerBase
      *
      * @param clearReferencesStopThreads The new flag value
      */
-    public void setClearReferencesStopThreads(
-            boolean clearReferencesStopThreads) {
+    public void setClearReferencesStopThreads(boolean clearReferencesStopThreads) {
 
         boolean oldClearReferencesStopThreads = this.clearReferencesStopThreads;
         this.clearReferencesStopThreads = clearReferencesStopThreads;
-        support.firePropertyChange("clearReferencesStopThreads",
-                                   oldClearReferencesStopThreads,
-                                   this.clearReferencesStopThreads);
+        support.firePropertyChange("clearReferencesStopThreads", oldClearReferencesStopThreads,
+                this.clearReferencesStopThreads);
 
     }
 
@@ -2679,21 +2533,17 @@ public class StandardContext extends ContainerBase
      *
      * @param clearReferencesStopTimerThreads The new flag value
      */
-    public void setClearReferencesStopTimerThreads(
-            boolean clearReferencesStopTimerThreads) {
+    public void setClearReferencesStopTimerThreads(boolean clearReferencesStopTimerThreads) {
 
-        boolean oldClearReferencesStopTimerThreads =
-            this.clearReferencesStopTimerThreads;
+        boolean oldClearReferencesStopTimerThreads = this.clearReferencesStopTimerThreads;
         this.clearReferencesStopTimerThreads = clearReferencesStopTimerThreads;
-        support.firePropertyChange("clearReferencesStopTimerThreads",
-                                   oldClearReferencesStopTimerThreads,
-                                   this.clearReferencesStopTimerThreads);
+        support.firePropertyChange("clearReferencesStopTimerThreads", oldClearReferencesStopTimerThreads,
+                this.clearReferencesStopTimerThreads);
     }
 
 
     /**
-     * @return the clearReferencesHttpClientKeepAliveThread flag for this
-     * Context.
+     * @return the clearReferencesHttpClientKeepAliveThread flag for this Context.
      */
     public boolean getClearReferencesHttpClientKeepAliveThread() {
         return this.clearReferencesHttpClientKeepAliveThread;
@@ -2701,15 +2551,12 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Set the clearReferencesHttpClientKeepAliveThread feature for this
-     * Context.
+     * Set the clearReferencesHttpClientKeepAliveThread feature for this Context.
      *
      * @param clearReferencesHttpClientKeepAliveThread The new flag value
      */
-    public void setClearReferencesHttpClientKeepAliveThread(
-            boolean clearReferencesHttpClientKeepAliveThread) {
-        this.clearReferencesHttpClientKeepAliveThread =
-            clearReferencesHttpClientKeepAliveThread;
+    public void setClearReferencesHttpClientKeepAliveThread(boolean clearReferencesHttpClientKeepAliveThread) {
+        this.clearReferencesHttpClientKeepAliveThread = clearReferencesHttpClientKeepAliveThread;
     }
 
 
@@ -2717,13 +2564,10 @@ public class StandardContext extends ContainerBase
         return this.renewThreadsWhenStoppingContext;
     }
 
-    public void setRenewThreadsWhenStoppingContext(
-            boolean renewThreadsWhenStoppingContext) {
-        boolean oldRenewThreadsWhenStoppingContext =
-                this.renewThreadsWhenStoppingContext;
+    public void setRenewThreadsWhenStoppingContext(boolean renewThreadsWhenStoppingContext) {
+        boolean oldRenewThreadsWhenStoppingContext = this.renewThreadsWhenStoppingContext;
         this.renewThreadsWhenStoppingContext = renewThreadsWhenStoppingContext;
-        support.firePropertyChange("renewThreadsWhenStoppingContext",
-                oldRenewThreadsWhenStoppingContext,
+        support.firePropertyChange("renewThreadsWhenStoppingContext", oldRenewThreadsWhenStoppingContext,
                 this.renewThreadsWhenStoppingContext);
     }
 
@@ -2733,13 +2577,10 @@ public class StandardContext extends ContainerBase
     }
 
 
-    public void setClearReferencesObjectStreamClassCaches(
-            boolean clearReferencesObjectStreamClassCaches) {
-        boolean oldClearReferencesObjectStreamClassCaches =
-                this.clearReferencesObjectStreamClassCaches;
+    public void setClearReferencesObjectStreamClassCaches(boolean clearReferencesObjectStreamClassCaches) {
+        boolean oldClearReferencesObjectStreamClassCaches = this.clearReferencesObjectStreamClassCaches;
         this.clearReferencesObjectStreamClassCaches = clearReferencesObjectStreamClassCaches;
-        support.firePropertyChange("clearReferencesObjectStreamClassCaches",
-                oldClearReferencesObjectStreamClassCaches,
+        support.firePropertyChange("clearReferencesObjectStreamClassCaches", oldClearReferencesObjectStreamClassCaches,
                 this.clearReferencesObjectStreamClassCaches);
     }
 
@@ -2752,8 +2593,7 @@ public class StandardContext extends ContainerBase
     public void setClearReferencesThreadLocals(boolean clearReferencesThreadLocals) {
         boolean oldClearReferencesThreadLocals = this.clearReferencesThreadLocals;
         this.clearReferencesThreadLocals = clearReferencesThreadLocals;
-        support.firePropertyChange("clearReferencesThreadLocals",
-                oldClearReferencesThreadLocals,
+        support.firePropertyChange("clearReferencesThreadLocals", oldClearReferencesThreadLocals,
                 this.clearReferencesThreadLocals);
     }
 
@@ -2772,32 +2612,29 @@ public class StandardContext extends ContainerBase
         return failCtxIfServletStartFails;
     }
 
-    public void setFailCtxIfServletStartFails(
-            Boolean failCtxIfServletStartFails) {
+    public void setFailCtxIfServletStartFails(Boolean failCtxIfServletStartFails) {
         Boolean oldFailCtxIfServletStartFails = this.failCtxIfServletStartFails;
         this.failCtxIfServletStartFails = failCtxIfServletStartFails;
-        support.firePropertyChange("failCtxIfServletStartFails",
-                oldFailCtxIfServletStartFails,
+        support.firePropertyChange("failCtxIfServletStartFails", oldFailCtxIfServletStartFails,
                 failCtxIfServletStartFails);
     }
 
     protected boolean getComputedFailCtxIfServletStartFails() {
-        if(failCtxIfServletStartFails != null) {
+        if (failCtxIfServletStartFails != null) {
             return failCtxIfServletStartFails.booleanValue();
         }
-        //else look at Host config
-        if(getParent() instanceof StandardHost) {
-            return ((StandardHost)getParent()).isFailCtxIfServletStartFails();
+        // else look at Host config
+        if (getParent() instanceof StandardHost) {
+            return ((StandardHost) getParent()).isFailCtxIfServletStartFails();
         }
-        //else
+        // else
         return false;
     }
 
     // -------------------------------------------------------- Context Methods
 
     /**
-     * Add a new Listener class name to the set of Listeners
-     * configured for this application.
+     * Add a new Listener class name to the set of Listeners configured for this application.
      *
      * @param listener Java class name of a listener class
      */
@@ -2808,7 +2645,7 @@ public class StandardContext extends ContainerBase
             String results[] = new String[applicationListeners.length + 1];
             for (int i = 0; i < applicationListeners.length; i++) {
                 if (listener.equals(applicationListeners[i])) {
-                    log.info(sm.getString("standardContext.duplicateListener",listener));
+                    log.info(sm.getString("standardContext.duplicateListener", listener));
                     return;
                 }
                 results[i] = applicationListeners[i];
@@ -2836,8 +2673,7 @@ public class StandardContext extends ContainerBase
                     return;
                 }
             }
-            ApplicationParameter results[] = Arrays.copyOf(
-                    applicationParameters, applicationParameters.length + 1);
+            ApplicationParameter results[] = Arrays.copyOf(applicationParameters, applicationParameters.length + 1);
             results[applicationParameters.length] = parameter;
             applicationParameters = results;
         }
@@ -2847,13 +2683,11 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Add a child Container, only if the proposed child is an implementation
-     * of Wrapper.
+     * Add a child Container, only if the proposed child is an implementation of Wrapper.
      *
      * @param child Child container to be added
      *
-     * @exception IllegalArgumentException if the proposed container is
-     *  not an implementation of Wrapper
+     * @exception IllegalArgumentException if the proposed container is not an implementation of Wrapper
      */
     @Override
     public void addChild(Container child) {
@@ -2862,8 +2696,7 @@ public class StandardContext extends ContainerBase
         Wrapper oldJspServlet = null;
 
         if (!(child instanceof Wrapper)) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.notWrapper"));
+            throw new IllegalArgumentException(sm.getString("standardContext.notWrapper"));
         }
 
         boolean isJspServlet = "jsp".equals(child.getName());
@@ -2880,11 +2713,11 @@ public class StandardContext extends ContainerBase
 
         if (isJspServlet && oldJspServlet != null) {
             /*
-             * The webapp-specific JspServlet inherits all the mappings
-             * specified in the global web.xml, and may add additional ones.
+             * The webapp-specific JspServlet inherits all the mappings specified in the global web.xml, and may add
+             * additional ones.
              */
             String[] jspMappings = oldJspServlet.findMappings();
-            for (int i=0; jspMappings!=null && i<jspMappings.length; i++) {
+            for (int i = 0; jspMappings != null && i < jspMappings.length; i++) {
                 addServletMappingDecoded(jspMappings[i], child.getName());
             }
         }
@@ -2906,23 +2739,18 @@ public class StandardContext extends ContainerBase
             for (int j = 0; j < patterns.length; j++) {
                 patterns[j] = adjustURLPattern(patterns[j]);
                 if (!validateURLPattern(patterns[j])) {
-                    throw new IllegalArgumentException
-                            (sm.getString
-                                    ("standardContext.securityConstraint.pattern",
-                                            patterns[j]));
+                    throw new IllegalArgumentException(
+                            sm.getString("standardContext.securityConstraint.pattern", patterns[j]));
                 }
             }
-            if (collection.findMethods().length > 0 &&
-                    collection.findOmittedMethods().length > 0) {
-                throw new IllegalArgumentException(sm.getString(
-                        "standardContext.securityConstraint.mixHttpMethod"));
+            if (collection.findMethods().length > 0 && collection.findOmittedMethods().length > 0) {
+                throw new IllegalArgumentException(sm.getString("standardContext.securityConstraint.mixHttpMethod"));
             }
         }
 
         // Add this constraint to the set for our web application
         synchronized (constraintsLock) {
-            SecurityConstraint results[] =
-                new SecurityConstraint[constraints.length + 1];
+            SecurityConstraint results[] = new SecurityConstraint[constraints.length + 1];
             for (int i = 0; i < constraints.length; i++) {
                 results[i] = constraints[i];
             }
@@ -2933,7 +2761,6 @@ public class StandardContext extends ContainerBase
     }
 
 
-
     /**
      * Add an error page for the specified error or Java exception.
      *
@@ -2943,21 +2770,17 @@ public class StandardContext extends ContainerBase
     public void addErrorPage(ErrorPage errorPage) {
         // Validate the input parameters
         if (errorPage == null) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.errorPage.required"));
+            throw new IllegalArgumentException(sm.getString("standardContext.errorPage.required"));
         }
         String location = errorPage.getLocation();
         if ((location != null) && !location.startsWith("/")) {
             if (isServlet22()) {
-                if(log.isDebugEnabled()) {
-                    log.debug(sm.getString("standardContext.errorPage.warning",
-                                 location));
+                if (log.isDebugEnabled()) {
+                    log.debug(sm.getString("standardContext.errorPage.warning", location));
                 }
                 errorPage.setLocation("/" + location);
             } else {
-                throw new IllegalArgumentException
-                    (sm.getString("standardContext.errorPage.error",
-                                  location));
+                throw new IllegalArgumentException(sm.getString("standardContext.errorPage.error", location));
             }
         }
 
@@ -2983,14 +2806,12 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Add a filter mapping to this Context at the end of the current set
-     * of filter mappings.
+     * Add a filter mapping to this Context at the end of the current set of filter mappings.
      *
      * @param filterMap The filter mapping to be added
      *
-     * @exception IllegalArgumentException if the specified filter name
-     *  does not match an existing filter definition, or the filter mapping
-     *  is malformed
+     * @exception IllegalArgumentException if the specified filter name does not match an existing filter definition, or
+     *                                         the filter mapping is malformed
      */
     @Override
     public void addFilterMap(FilterMap filterMap) {
@@ -3002,14 +2823,13 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Add a filter mapping to this Context before the mappings defined in the
-     * deployment descriptor but after any other mappings added via this method.
+     * Add a filter mapping to this Context before the mappings defined in the deployment descriptor but after any other
+     * mappings added via this method.
      *
      * @param filterMap The filter mapping to be added
      *
-     * @exception IllegalArgumentException if the specified filter name
-     *  does not match an existing filter definition, or the filter mapping
-     *  is malformed
+     * @exception IllegalArgumentException if the specified filter name does not match an existing filter definition, or
+     *                                         the filter mapping is malformed
      */
     @Override
     public void addFilterMapBefore(FilterMap filterMap) {
@@ -3031,21 +2851,16 @@ public class StandardContext extends ContainerBase
         String[] servletNames = filterMap.getServletNames();
         String[] urlPatterns = filterMap.getURLPatterns();
         if (findFilterDef(filterName) == null) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.filterMap.name", filterName));
+            throw new IllegalArgumentException(sm.getString("standardContext.filterMap.name", filterName));
         }
 
-        if (!filterMap.getMatchAllServletNames() &&
-            !filterMap.getMatchAllUrlPatterns() &&
-            (servletNames.length == 0) && (urlPatterns.length == 0)) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.filterMap.either"));
+        if (!filterMap.getMatchAllServletNames() && !filterMap.getMatchAllUrlPatterns() && (servletNames.length == 0) &&
+                (urlPatterns.length == 0)) {
+            throw new IllegalArgumentException(sm.getString("standardContext.filterMap.either"));
         }
         for (String urlPattern : urlPatterns) {
             if (!validateURLPattern(urlPattern)) {
-                throw new IllegalArgumentException
-                        (sm.getString("standardContext.filterMap.pattern",
-                                urlPattern));
+                throw new IllegalArgumentException(sm.getString("standardContext.filterMap.pattern", urlPattern));
             }
         }
     }
@@ -3054,11 +2869,11 @@ public class StandardContext extends ContainerBase
     /**
      * Add a Locale Encoding Mapping (see Sec 5.4 of Servlet spec 2.4)
      *
-     * @param locale locale to map an encoding for
+     * @param locale   locale to map an encoding for
      * @param encoding encoding to be used for a give locale
      */
     @Override
-    public void addLocaleEncodingMappingParameter(String locale, String encoding){
+    public void addLocaleEncodingMappingParameter(String locale, String encoding) {
         getCharsetMapper().addCharsetMappingFromDeploymentDescriptor(locale, encoding);
     }
 
@@ -3083,8 +2898,7 @@ public class StandardContext extends ContainerBase
      *
      * @param mdr New message destination reference
      */
-    public void addMessageDestinationRef
-        (MessageDestinationRef mdr) {
+    public void addMessageDestinationRef(MessageDestinationRef mdr) {
 
         namingResources.addMessageDestinationRef(mdr);
         fireContainerEvent("addMessageDestinationRef", mdr.getName());
@@ -3093,11 +2907,10 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Add a new MIME mapping, replacing any existing mapping for
-     * the specified extension.
+     * Add a new MIME mapping, replacing any existing mapping for the specified extension.
      *
      * @param extension Filename extension being mapped
-     * @param mimeType Corresponding MIME type
+     * @param mimeType  Corresponding MIME type
      */
     @Override
     public void addMimeMapping(String extension, String mimeType) {
@@ -3113,27 +2926,24 @@ public class StandardContext extends ContainerBase
     /**
      * Add a new context initialization parameter.
      *
-     * @param name Name of the new parameter
-     * @param value Value of the new  parameter
+     * @param name  Name of the new parameter
+     * @param value Value of the new parameter
      *
-     * @exception IllegalArgumentException if the name or value is missing,
-     *  or if this context initialization parameter has already been
-     *  registered
+     * @exception IllegalArgumentException if the name or value is missing, or if this context initialization parameter
+     *                                         has already been registered
      */
     @Override
     public void addParameter(String name, String value) {
         // Validate the proposed context initialization parameter
         if ((name == null) || (value == null)) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.parameter.required"));
+            throw new IllegalArgumentException(sm.getString("standardContext.parameter.required"));
         }
 
         // Add this parameter to our defined set if not already present
         String oldValue = parameters.putIfAbsent(name, value);
 
         if (oldValue != null) {
-            throw new IllegalArgumentException(
-                    sm.getString("standardContext.parameter.duplicate", name));
+            throw new IllegalArgumentException(sm.getString("standardContext.parameter.duplicate", name));
         }
 
         fireContainerEvent("addParameter", name);
@@ -3166,7 +2976,7 @@ public class StandardContext extends ContainerBase
     public void addSecurityRole(String role) {
 
         synchronized (securityRolesLock) {
-            String results[] =new String[securityRoles.length + 1];
+            String results[] = new String[securityRoles.length + 1];
             for (int i = 0; i < securityRoles.length; i++) {
                 results[i] = securityRoles[i];
             }
@@ -3199,17 +3009,14 @@ public class StandardContext extends ContainerBase
 
 
     @Override
-    public void addServletMappingDecoded(String pattern, String name,
-                                  boolean jspWildCard) {
+    public void addServletMappingDecoded(String pattern, String name, boolean jspWildCard) {
         // Validate the proposed mapping
         if (findChild(name) == null) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.servletMap.name", name));
+            throw new IllegalArgumentException(sm.getString("standardContext.servletMap.name", name));
         }
         String adjustedPattern = adjustURLPattern(pattern);
         if (!validateURLPattern(adjustedPattern)) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.servletMap.pattern", adjustedPattern));
+            throw new IllegalArgumentException(sm.getString("standardContext.servletMap.pattern", adjustedPattern));
         }
 
         // Add this mapping to our registered set
@@ -3265,22 +3072,21 @@ public class StandardContext extends ContainerBase
                 welcomeFiles = new String[0];
                 setReplaceWelcomeFiles(false);
             }
-            String results[] =new String[welcomeFiles.length + 1];
+            String results[] = new String[welcomeFiles.length + 1];
             for (int i = 0; i < welcomeFiles.length; i++) {
                 results[i] = welcomeFiles[i];
             }
             results[welcomeFiles.length] = name;
             welcomeFiles = results;
         }
-        if(this.getState().equals(LifecycleState.STARTED)) {
+        if (this.getState().equals(LifecycleState.STARTED)) {
             fireContainerEvent(ADD_WELCOME_FILE_EVENT, name);
         }
     }
 
 
     /**
-     * Add the classname of a LifecycleListener to be added to each
-     * Wrapper appended to this Context.
+     * Add the classname of a LifecycleListener to be added to each Wrapper appended to this Context.
      *
      * @param listener Java class name of a LifecycleListener class
      */
@@ -3288,7 +3094,7 @@ public class StandardContext extends ContainerBase
     public void addWrapperLifecycle(String listener) {
 
         synchronized (wrapperLifecyclesLock) {
-            String results[] =new String[wrapperLifecycles.length + 1];
+            String results[] = new String[wrapperLifecycles.length + 1];
             for (int i = 0; i < wrapperLifecycles.length; i++) {
                 results[i] = wrapperLifecycles[i];
             }
@@ -3301,8 +3107,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Add the classname of a ContainerListener to be added to each
-     * Wrapper appended to this Context.
+     * Add the classname of a ContainerListener to be added to each Wrapper appended to this Context.
      *
      * @param listener Java class name of a ContainerListener class
      */
@@ -3310,7 +3115,7 @@ public class StandardContext extends ContainerBase
     public void addWrapperListener(String listener) {
 
         synchronized (wrapperListenersLock) {
-            String results[] =new String[wrapperListeners.length + 1];
+            String results[] = new String[wrapperListeners.length + 1];
             for (int i = 0; i < wrapperListeners.length; i++) {
                 results[i] = wrapperListeners[i];
             }
@@ -3323,10 +3128,9 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Factory method to create and return a new Wrapper instance, of
-     * the Java implementation class appropriate for this Context
-     * implementation.  The constructor of the instantiated Wrapper
-     * will have been called, but no properties will have been set.
+     * Factory method to create and return a new Wrapper instance, of the Java implementation class appropriate for this
+     * Context implementation. The constructor of the instantiated Wrapper will have been called, but no properties will
+     * have been set.
      */
     @Override
     public Wrapper createWrapper() {
@@ -3348,8 +3152,7 @@ public class StandardContext extends ContainerBase
             for (String wrapperLifecycle : wrapperLifecycles) {
                 try {
                     Class<?> clazz = Class.forName(wrapperLifecycle);
-                    LifecycleListener listener =
-                            (LifecycleListener) clazz.getConstructor().newInstance();
+                    LifecycleListener listener = (LifecycleListener) clazz.getConstructor().newInstance();
                     wrapper.addLifecycleListener(listener);
                 } catch (Throwable t) {
                     ExceptionUtils.handleThrowable(t);
@@ -3363,8 +3166,7 @@ public class StandardContext extends ContainerBase
             for (String wrapperListener : wrapperListeners) {
                 try {
                     Class<?> clazz = Class.forName(wrapperListener);
-                    ContainerListener listener =
-                            (ContainerListener) clazz.getConstructor().newInstance();
+                    ContainerListener listener = (ContainerListener) clazz.getConstructor().newInstance();
                     wrapper.addContainerListener(listener);
                 } catch (Throwable t) {
                     ExceptionUtils.handleThrowable(t);
@@ -3379,8 +3181,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Return the set of application listener class names configured
-     * for this application.
+     * Return the set of application listener class names configured for this application.
      */
     @Override
     public String[] findApplicationListeners() {
@@ -3402,8 +3203,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Return the security constraints for this web application.
-     * If there are none, a zero-length array is returned.
+     * Return the security constraints for this web application. If there are none, a zero-length array is returned.
      */
     @Override
     public SecurityConstraint[] findConstraints() {
@@ -3412,8 +3212,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Return the error page entry for the specified HTTP error code,
-     * if any; otherwise return <code>null</code>.
+     * Return the error page entry for the specified HTTP error code, if any; otherwise return <code>null</code>.
      *
      * @param errorCode Error code to look up
      */
@@ -3437,8 +3236,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Return the set of defined error pages for all specified error codes
-     * and exception types.
+     * Return the set of defined error pages for all specified error codes and exception types.
      */
     @Override
     public ErrorPage[] findErrorPages() {
@@ -3447,8 +3245,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Return the filter definition for the specified filter name, if any;
-     * otherwise return <code>null</code>.
+     * Return the filter definition for the specified filter name, if any; otherwise return <code>null</code>.
      *
      * @param filterName Filter name to look up
      */
@@ -3481,8 +3278,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the message destination with the specified name, if any;
-     * otherwise, return <code>null</code>.
+     * @return the message destination with the specified name, if any; otherwise, return <code>null</code>.
      *
      * @param name Name of the desired message destination
      */
@@ -3494,9 +3290,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the set of defined message destinations for this web
-     * application.  If none have been defined, a zero-length array
-     * is returned.
+     * @return the set of defined message destinations for this web application. If none have been defined, a
+     *             zero-length array is returned.
      */
     public MessageDestination[] findMessageDestinations() {
         synchronized (messageDestinations) {
@@ -3506,8 +3301,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the message destination ref with the specified name, if any;
-     * otherwise, return <code>null</code>.
+     * @return the message destination ref with the specified name, if any; otherwise, return <code>null</code>.
      *
      * @param name Name of the desired message destination ref
      */
@@ -3517,9 +3311,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the set of defined message destination refs for this web
-     * application.  If none have been defined, a zero-length array
-     * is returned.
+     * @return the set of defined message destination refs for this web application. If none have been defined, a
+     *             zero-length array is returned.
      */
     public MessageDestinationRef[] findMessageDestinationRefs() {
         return namingResources.findMessageDestinationRefs();
@@ -3527,8 +3320,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the MIME type to which the specified extension is mapped,
-     * if any; otherwise return <code>null</code>.
+     * @return the MIME type to which the specified extension is mapped, if any; otherwise return <code>null</code>.
      *
      * @param extension Extension to map to a MIME type
      */
@@ -3539,8 +3331,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the extensions for which MIME mappings are defined.  If there
-     * are none, a zero-length array is returned.
+     * @return the extensions for which MIME mappings are defined. If there are none, a zero-length array is returned.
      */
     @Override
     public String[] findMimeMappings() {
@@ -3551,8 +3342,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the value for the specified context initialization
-     * parameter name, if any; otherwise return <code>null</code>.
+     * @return the value for the specified context initialization parameter name, if any; otherwise return
+     *             <code>null</code>.
      *
      * @param name Name of the parameter to return
      */
@@ -3563,9 +3354,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the names of all defined context initialization parameters
-     * for this Context.  If no parameters are defined, a zero-length
-     * array is returned.
+     * @return the names of all defined context initialization parameters for this Context. If no parameters are
+     *             defined, a zero-length array is returned.
      */
     @Override
     public String[] findParameters() {
@@ -3574,11 +3364,11 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * For the given security role (as used by an application), return the
-     * corresponding role name (as defined by the underlying Realm) if there
-     * is one.  Otherwise, return the specified role unchanged.
+     * For the given security role (as used by an application), return the corresponding role name (as defined by the
+     * underlying Realm) if there is one. Otherwise, return the specified role unchanged.
      *
      * @param role Security role to map
+     *
      * @return the role name
      */
     @Override
@@ -3596,8 +3386,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return <code>true</code> if the specified security role is defined
-     * for this application; otherwise return <code>false</code>.
+     * @return <code>true</code> if the specified security role is defined for this application; otherwise return
+     *             <code>false</code>.
      *
      * @param role Security role to verify
      */
@@ -3617,8 +3407,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the security roles defined for this application.  If none
-     * have been defined, a zero-length array is returned.
+     * @return the security roles defined for this application. If none have been defined, a zero-length array is
+     *             returned.
      */
     @Override
     public String[] findSecurityRoles() {
@@ -3629,8 +3419,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the servlet name mapped by the specified pattern (if any);
-     * otherwise return <code>null</code>.
+     * @return the servlet name mapped by the specified pattern (if any); otherwise return <code>null</code>.
      *
      * @param pattern Pattern for which a mapping is requested
      */
@@ -3643,8 +3432,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the patterns of all defined servlet mappings for this
-     * Context.  If no mappings are defined, a zero-length array is returned.
+     * @return the patterns of all defined servlet mappings for this Context. If no mappings are defined, a zero-length
+     *             array is returned.
      */
     @Override
     public String[] findServletMappings() {
@@ -3685,8 +3474,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return <code>true</code> if the specified welcome file is defined
-     * for this Context; otherwise return <code>false</code>.
+     * @return <code>true</code> if the specified welcome file is defined for this Context; otherwise return
+     *             <code>false</code>.
      *
      * @param name Welcome file to verify
      */
@@ -3706,8 +3495,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the set of watched resources for this Context. If none are
-     * defined, a zero length array will be returned.
+     * @return the set of watched resources for this Context. If none are defined, a zero length array will be returned.
      */
     @Override
     public String[] findWatchedResources() {
@@ -3718,8 +3506,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the set of welcome files defined for this Context.  If none are
-     * defined, a zero-length array is returned.
+     * @return the set of welcome files defined for this Context. If none are defined, a zero-length array is returned.
      */
     @Override
     public String[] findWelcomeFiles() {
@@ -3730,8 +3517,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the set of LifecycleListener classes that will be added to
-     * newly created Wrappers automatically.
+     * @return the set of LifecycleListener classes that will be added to newly created Wrappers automatically.
      */
     @Override
     public String[] findWrapperLifecycles() {
@@ -3742,8 +3528,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * @return the set of ContainerListener classes that will be added to
-     * newly created Wrappers automatically.
+     * @return the set of ContainerListener classes that will be added to newly created Wrappers automatically.
      */
     @Override
     public String[] findWrapperListeners() {
@@ -3756,30 +3541,24 @@ public class StandardContext extends ContainerBase
     /**
      * Reload this web application, if reloading is supported.
      * <p>
-     * <b>IMPLEMENTATION NOTE</b>:  This method is designed to deal with
-     * reloads required by changes to classes in the underlying repositories
-     * of our class loader and changes to the web.xml file. It does not handle
-     * changes to any context.xml file. If the context.xml has changed, you
-     * should stop this Context and create (and start) a new Context instance
-     * instead. Note that there is additional code in
-     * <code>CoyoteAdapter#postParseRequest()</code> to handle mapping requests
-     * to paused Contexts.
+     * <b>IMPLEMENTATION NOTE</b>: This method is designed to deal with reloads required by changes to classes in the
+     * underlying repositories of our class loader and changes to the web.xml file. It does not handle changes to any
+     * context.xml file. If the context.xml has changed, you should stop this Context and create (and start) a new
+     * Context instance instead. Note that there is additional code in <code>CoyoteAdapter#postParseRequest()</code> to
+     * handle mapping requests to paused Contexts.
      *
-     * @exception IllegalStateException if the <code>reloadable</code>
-     *  property is set to <code>false</code>.
+     * @exception IllegalStateException if the <code>reloadable</code> property is set to <code>false</code>.
      */
     @Override
     public synchronized void reload() {
 
         // Validate our current component state
         if (!getState().isAvailable()) {
-            throw new IllegalStateException
-                (sm.getString("standardContext.notStarted", getName()));
+            throw new IllegalStateException(sm.getString("standardContext.notStarted", getName()));
         }
 
-        if(log.isInfoEnabled()) {
-            log.info(sm.getString("standardContext.reloadingStarted",
-                    getName()));
+        if (log.isInfoEnabled()) {
+            log.info(sm.getString("standardContext.reloadingStarted", getName()));
         }
 
         // Stop accepting requests temporarily.
@@ -3788,30 +3567,26 @@ public class StandardContext extends ContainerBase
         try {
             stop();
         } catch (LifecycleException e) {
-            log.error(
-                sm.getString("standardContext.stoppingContext", getName()), e);
+            log.error(sm.getString("standardContext.stoppingContext", getName()), e);
         }
 
         try {
             start();
         } catch (LifecycleException e) {
-            log.error(
-                sm.getString("standardContext.startingContext", getName()), e);
+            log.error(sm.getString("standardContext.startingContext", getName()), e);
         }
 
         setPaused(false);
 
-        if(log.isInfoEnabled()) {
-            log.info(sm.getString("standardContext.reloadingCompleted",
-                    getName()));
+        if (log.isInfoEnabled()) {
+            log.info(sm.getString("standardContext.reloadingCompleted", getName()));
         }
 
     }
 
 
     /**
-     * Remove the specified application listener class from the set of
-     * listeners for this application.
+     * Remove the specified application listener class from the set of listeners for this application.
      *
      * @param listener Java class name of the listener to be removed
      */
@@ -3851,8 +3626,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove the application parameter with the specified name from
-     * the set for this application.
+     * Remove the application parameter with the specified name from the set for this application.
      *
      * @param name Name of the application parameter to remove
      */
@@ -3875,8 +3649,7 @@ public class StandardContext extends ContainerBase
 
             // Remove the specified parameter
             int j = 0;
-            ApplicationParameter results[] =
-                new ApplicationParameter[applicationParameters.length - 1];
+            ApplicationParameter results[] = new ApplicationParameter[applicationParameters.length - 1];
             for (int i = 0; i < applicationParameters.length; i++) {
                 if (i != n) {
                     results[j++] = applicationParameters[i];
@@ -3893,20 +3666,17 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Add a child Container, only if the proposed child is an implementation
-     * of Wrapper.
+     * Add a child Container, only if the proposed child is an implementation of Wrapper.
      *
      * @param child Child container to be added
      *
-     * @exception IllegalArgumentException if the proposed container is
-     *  not an implementation of Wrapper
+     * @exception IllegalArgumentException if the proposed container is not an implementation of Wrapper
      */
     @Override
     public void removeChild(Container child) {
 
         if (!(child instanceof Wrapper)) {
-            throw new IllegalArgumentException
-                (sm.getString("standardContext.notWrapper"));
+            throw new IllegalArgumentException(sm.getString("standardContext.notWrapper"));
         }
 
         super.removeChild(child);
@@ -3938,8 +3708,7 @@ public class StandardContext extends ContainerBase
 
             // Remove the specified constraint
             int j = 0;
-            SecurityConstraint results[] =
-                new SecurityConstraint[constraints.length - 1];
+            SecurityConstraint results[] = new SecurityConstraint[constraints.length - 1];
             for (int i = 0; i < constraints.length; i++) {
                 if (i != n) {
                     results[j++] = constraints[i];
@@ -3956,8 +3725,8 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove the error page for the specified error code or
-     * Java language exception, if it exists; otherwise, no action is taken.
+     * Remove the error page for the specified error code or Java language exception, if it exists; otherwise, no action
+     * is taken.
      *
      * @param errorPage The error page definition to be removed
      */
@@ -3969,8 +3738,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove the specified filter definition from this Context, if it exists;
-     * otherwise, no action is taken.
+     * Remove the specified filter definition from this Context, if it exists; otherwise, no action is taken.
      *
      * @param filterDef Filter definition to be removed
      */
@@ -4027,8 +3795,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove the MIME mapping for the specified extension, if it exists;
-     * otherwise, no action is taken.
+     * Remove the MIME mapping for the specified extension, if it exists; otherwise, no action is taken.
      *
      * @param extension Extension to remove the mapping for
      */
@@ -4044,8 +3811,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove the context initialization parameter with the specified
-     * name, if it exists; otherwise, no action is taken.
+     * Remove the context initialization parameter with the specified name, if it exists; otherwise, no action is taken.
      *
      * @param name Name of the parameter to remove
      */
@@ -4113,8 +3879,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove any servlet mapping for the specified pattern, if it exists;
-     * otherwise, no action is taken.
+     * Remove any servlet mapping for the specified pattern, if it exists; otherwise, no action is taken.
      *
      * @param pattern URL pattern of the mapping to remove
      */
@@ -4126,7 +3891,7 @@ public class StandardContext extends ContainerBase
             name = servletMappings.remove(pattern);
         }
         Wrapper wrapper = (Wrapper) findChild(name);
-        if( wrapper != null ) {
+        if (wrapper != null) {
             wrapper.removeMapping(pattern);
         }
         fireContainerEvent("removeServletMapping", pattern);
@@ -4134,8 +3899,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove the specified watched resource name from the list associated
-     * with this Context.
+     * Remove the specified watched resource name from the list associated with this Context.
      *
      * @param name Name of the watched resource to be removed
      */
@@ -4174,8 +3938,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove the specified welcome file name from the list recognized
-     * by this Context.
+     * Remove the specified welcome file name from the list recognized by this Context.
      *
      * @param name Name of the welcome file to be removed
      */
@@ -4209,7 +3972,7 @@ public class StandardContext extends ContainerBase
         }
 
         // Inform interested listeners
-        if(this.getState().equals(LifecycleState.STARTED)) {
+        if (this.getState().equals(LifecycleState.STARTED)) {
             fireContainerEvent(REMOVE_WELCOME_FILE_EVENT, name);
         }
 
@@ -4217,8 +3980,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove a class name from the set of LifecycleListener classes that
-     * will be added to newly created Wrappers.
+     * Remove a class name from the set of LifecycleListener classes that will be added to newly created Wrappers.
      *
      * @param listener Class name of a LifecycleListener class to be removed
      */
@@ -4259,8 +4021,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Remove a class name from the set of ContainerListener classes that
-     * will be added to newly created Wrappers.
+     * Remove a class name from the set of ContainerListener classes that will be added to newly created Wrappers.
      *
      * @param listener Class name of a ContainerListener class to be removed
      */
@@ -4301,11 +4062,9 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Gets the cumulative processing times of all servlets in this
-     * StandardContext.
+     * Gets the cumulative processing times of all servlets in this StandardContext.
      *
-     * @return Cumulative processing times of all servlets in this
-     * StandardContext
+     * @return Cumulative processing times of all servlets in this StandardContext
      */
     public long getProcessingTime() {
 
@@ -4322,11 +4081,9 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Gets the maximum processing time of all servlets in this
-     * StandardContext.
+     * Gets the maximum processing time of all servlets in this StandardContext.
      *
-     * @return Maximum processing time of all servlets in this
-     * StandardContext
+     * @return Maximum processing time of all servlets in this StandardContext
      */
     public long getMaxTime() {
 
@@ -4347,11 +4104,9 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Gets the minimum processing time of all servlets in this
-     * StandardContext.
+     * Gets the minimum processing time of all servlets in this StandardContext.
      *
-     * @return Minimum processing time of all servlets in this
-     * StandardContext
+     * @return Minimum processing time of all servlets in this StandardContext
      */
     public long getMinTime() {
 
@@ -4372,11 +4127,9 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Gets the cumulative request count of all servlets in this
-     * StandardContext.
+     * Gets the cumulative request count of all servlets in this StandardContext.
      *
-     * @return Cumulative request count of all servlets in this
-     * StandardContext
+     * @return Cumulative request count of all servlets in this StandardContext
      */
     public int getRequestCount() {
 
@@ -4393,11 +4146,9 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Gets the cumulative error count of all servlets in this
-     * StandardContext.
+     * Gets the cumulative error count of all servlets in this StandardContext.
      *
-     * @return Cumulative error count of all servlets in this
-     * StandardContext
+     * @return Cumulative error count of all servlets in this StandardContext
      */
     public int getErrorCount() {
 
@@ -4415,8 +4166,7 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Return the real path for a given virtual path, if possible; otherwise
-     * return <code>null</code>.
+     * Return the real path for a given virtual path, if possible; otherwise return <code>null</code>.
      *
      * @param path The path to the desired resource
      */
@@ -4433,8 +4183,8 @@ public class StandardContext extends ContainerBase
                 String canonicalPath = resource.getCanonicalPath();
                 if (canonicalPath == null) {
                     return null;
-                } else if ((resource.isDirectory() && !canonicalPath.endsWith(File.separator) ||
-                        !resource.exists()) && path.endsWith("/")) {
+                } else if ((resource.isDirectory() && !canonicalPath.endsWith(File.separator) || !resource.exists()) &&
+                        path.endsWith("/")) {
                     return canonicalPath + File.separatorChar;
                 } else {
                     return canonicalPath;
@@ -4453,8 +4203,7 @@ public class StandardContext extends ContainerBase
      *
      * @return An appropriate registration
      *
-     * @deprecated This will be removed in Tomcat 9. The registration should be
-     *             created directly.
+     * @deprecated This will be removed in Tomcat 9. The registration should be created directly.
      */
     @Deprecated
     public ServletRegistration.Dynamic dynamicServletAdded(Wrapper wrapper) {
@@ -4462,8 +4211,7 @@ public class StandardContext extends ContainerBase
     }
 
     /**
-     * Hook to track which Servlets were created via
-     * {@link ServletContext#createServlet(Class)}.
+     * Hook to track which Servlets were created via {@link ServletContext#createServlet(Class)}.
      *
      * @param servlet the created Servlet
      */
@@ -4484,21 +4232,18 @@ public class StandardContext extends ContainerBase
         private final Object lock = new Object();
 
         /**
-         * The set of filter mappings for this application, in the order they
-         * were defined in the deployment descriptor with additional mappings
-         * added via the {@link ServletContext} possibly both before and after
-         * those defined in the deployment descriptor.
+         * The set of filter mappings for this application, in the order they were defined in the deployment descriptor
+         * with additional mappings added via the {@link ServletContext} possibly both before and after those defined in
+         * the deployment descriptor.
          */
         private FilterMap[] array = new FilterMap[0];
 
         /**
-         * Filter mappings added via {@link ServletContext} may have to be
-         * inserted before the mappings in the deployment descriptor but must be
-         * inserted in the order the {@link ServletContext} methods are called.
-         * This isn't an issue for the mappings added after the deployment
-         * descriptor - they are just added to the end - but correctly the
-         * adding mappings before the deployment descriptor mappings requires
-         * knowing where the last 'before' mapping was added.
+         * Filter mappings added via {@link ServletContext} may have to be inserted before the mappings in the
+         * deployment descriptor but must be inserted in the order the {@link ServletContext} methods are called. This
+         * isn't an issue for the mappings added after the deployment descriptor - they are just added to the end - but
+         * correctly the adding mappings before the deployment descriptor mappings requires knowing where the last
+         * 'before' mapping was added.
          */
         private int insertPoint = 0;
 
@@ -4512,11 +4257,9 @@ public class StandardContext extends ContainerBase
         }
 
         /**
-         * Add a filter mapping at the end of the current set of filter
-         * mappings.
+         * Add a filter mapping at the end of the current set of filter mappings.
          *
-         * @param filterMap
-         *            The filter mapping to be added
+         * @param filterMap The filter mapping to be added
          */
         public void add(FilterMap filterMap) {
             synchronized (lock) {
@@ -4527,18 +4270,16 @@ public class StandardContext extends ContainerBase
         }
 
         /**
-         * Add a filter mapping before the mappings defined in the deployment
-         * descriptor but after any other mappings added via this method.
+         * Add a filter mapping before the mappings defined in the deployment descriptor but after any other mappings
+         * added via this method.
          *
-         * @param filterMap
-         *            The filter mapping to be added
+         * @param filterMap The filter mapping to be added
          */
         public void addBefore(FilterMap filterMap) {
             synchronized (lock) {
                 FilterMap results[] = new FilterMap[array.length + 1];
                 System.arraycopy(array, 0, results, 0, insertPoint);
-                System.arraycopy(array, insertPoint, results, insertPoint + 1,
-                        array.length - insertPoint);
+                System.arraycopy(array, insertPoint, results, insertPoint + 1, array.length - insertPoint);
                 results[insertPoint] = filterMap;
                 array = results;
                 insertPoint++;
@@ -4567,8 +4308,7 @@ public class StandardContext extends ContainerBase
                 // Remove the specified filter mapping
                 FilterMap results[] = new FilterMap[array.length - 1];
                 System.arraycopy(array, 0, results, 0, n);
-                System.arraycopy(array, n + 1, results, n, (array.length - 1)
-                        - n);
+                System.arraycopy(array, n + 1, results, n, (array.length - 1) - n);
                 array = results;
                 if (n < insertPoint) {
                     insertPoint--;
@@ -4582,8 +4322,8 @@ public class StandardContext extends ContainerBase
 
     /**
      * Configure and initialize the set of filters for this Context.
-     * @return <code>true</code> if all filter initialization completed
-     * successfully, or <code>false</code> otherwise.
+     *
+     * @return <code>true</code> if all filter initialization completed successfully, or <code>false</code> otherwise.
      */
     public boolean filterStart() {
 
@@ -4594,20 +4334,18 @@ public class StandardContext extends ContainerBase
         boolean ok = true;
         synchronized (filterConfigs) {
             filterConfigs.clear();
-            for (Entry<String,FilterDef> entry : filterDefs.entrySet()) {
+            for (Entry<String, FilterDef> entry : filterDefs.entrySet()) {
                 String name = entry.getKey();
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug(" Starting filter '" + name + "'");
                 }
                 try {
-                    ApplicationFilterConfig filterConfig =
-                            new ApplicationFilterConfig(this, entry.getValue());
+                    ApplicationFilterConfig filterConfig = new ApplicationFilterConfig(this, entry.getValue());
                     filterConfigs.put(name, filterConfig);
                 } catch (Throwable t) {
                     t = ExceptionUtils.unwrapInvocationTargetException(t);
                     ExceptionUtils.handleThrowable(t);
-                    getLogger().error(sm.getString(
-                            "standardContext.filterStart", name), t);
+                    getLogger().error(sm.getString("standardContext.filterStart", name), t);
                     ok = false;
                 }
             }
@@ -4619,8 +4357,8 @@ public class StandardContext extends ContainerBase
 
     /**
      * Finalize and release the set of filters for this Context.
-     * @return <code>true</code> if all filter finalization completed
-     * successfully, or <code>false</code> otherwise.
+     *
+     * @return <code>true</code> if all filter finalization completed successfully, or <code>false</code> otherwise.
      */
     public boolean filterStop() {
 
@@ -4645,10 +4383,11 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Find and return the initialized <code>FilterConfig</code> for the
-     * specified filter name, if any; otherwise return <code>null</code>.
+     * Find and return the initialized <code>FilterConfig</code> for the specified filter name, if any; otherwise return
+     * <code>null</code>.
      *
      * @param name Name of the desired filter
+     *
      * @return the filter config object
      */
     public FilterConfig findFilterConfig(String name) {
@@ -4657,10 +4396,9 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Configure the set of instantiated application event listeners
-     * for this Context.
-     * @return <code>true</code> if all listeners wre
-     * initialized successfully, or <code>false</code> otherwise.
+     * Configure the set of instantiated application event listeners for this Context.
+     *
+     * @return <code>true</code> if all listeners wre initialized successfully, or <code>false</code> otherwise.
      */
     public boolean listenerStart() {
 
@@ -4674,8 +4412,7 @@ public class StandardContext extends ContainerBase
         boolean ok = true;
         for (int i = 0; i < results.length; i++) {
             if (getLogger().isDebugEnabled()) {
-                getLogger().debug(" Configuring event listener class '" +
-                    listeners[i] + "'");
+                getLogger().debug(" Configuring event listener class '" + listeners[i] + "'");
             }
             try {
                 String listener = listeners[i];
@@ -4683,8 +4420,7 @@ public class StandardContext extends ContainerBase
             } catch (Throwable t) {
                 t = ExceptionUtils.unwrapInvocationTargetException(t);
                 ExceptionUtils.handleThrowable(t);
-                getLogger().error(sm.getString(
-                        "standardContext.applicationListener", listeners[i]), t);
+                getLogger().error(sm.getString("standardContext.applicationListener", listeners[i]), t);
                 ok = false;
             }
         }
@@ -4697,15 +4433,12 @@ public class StandardContext extends ContainerBase
         List<Object> eventListeners = new ArrayList<>();
         List<Object> lifecycleListeners = new ArrayList<>();
         for (Object result : results) {
-            if ((result instanceof ServletContextAttributeListener)
-                    || (result instanceof ServletRequestAttributeListener)
-                    || (result instanceof ServletRequestListener)
-                    || (result instanceof HttpSessionIdListener)
-                    || (result instanceof HttpSessionAttributeListener)) {
+            if ((result instanceof ServletContextAttributeListener) ||
+                    (result instanceof ServletRequestAttributeListener) || (result instanceof ServletRequestListener) ||
+                    (result instanceof HttpSessionIdListener) || (result instanceof HttpSessionAttributeListener)) {
                 eventListeners.add(result);
             }
-            if ((result instanceof ServletContextListener)
-                    || (result instanceof HttpSessionListener)) {
+            if ((result instanceof ServletContextListener) || (result instanceof HttpSessionListener)) {
                 lifecycleListeners.add(result);
             }
         }
@@ -4717,7 +4450,7 @@ public class StandardContext extends ContainerBase
         // list.
         eventListeners.addAll(Arrays.asList(getApplicationEventListeners()));
         setApplicationEventListeners(eventListeners.toArray());
-        for (Object lifecycleListener: getApplicationLifecycleListeners()) {
+        for (Object lifecycleListener : getApplicationLifecycleListeners()) {
             lifecycleListeners.add(lifecycleListener);
             if (lifecycleListener instanceof ServletContextListener) {
                 noPluggabilityListeners.add(lifecycleListener);
@@ -4762,8 +4495,7 @@ public class StandardContext extends ContainerBase
             } catch (Throwable t) {
                 ExceptionUtils.handleThrowable(t);
                 fireContainerEvent("afterContextInitialized", listener);
-                getLogger().error(sm.getString("standardContext.listenerStart",
-                        instance.getClass().getName()), t);
+                getLogger().error(sm.getString("standardContext.listenerStart", instance.getClass().getName()), t);
                 ok = false;
             }
         }
@@ -4774,8 +4506,8 @@ public class StandardContext extends ContainerBase
 
     /**
      * Send an application stop event to all interested listeners.
-     * @return <code>true</code> if all events were sent successfully,
-     * or <code>false</code> otherwise.
+     *
+     * @return <code>true</code> if all events were sent successfully, or <code>false</code> otherwise.
      */
     public boolean listenerStop() {
 
@@ -4797,8 +4529,7 @@ public class StandardContext extends ContainerBase
                     continue;
                 }
                 if (listeners[j] instanceof ServletContextListener) {
-                    ServletContextListener listener =
-                        (ServletContextListener) listeners[j];
+                    ServletContextListener listener = (ServletContextListener) listeners[j];
                     try {
                         fireContainerEvent("beforeContextDestroyed", listener);
                         if (noPluggabilityListeners.contains(listener)) {
@@ -4810,9 +4541,8 @@ public class StandardContext extends ContainerBase
                     } catch (Throwable t) {
                         ExceptionUtils.handleThrowable(t);
                         fireContainerEvent("afterContextDestroyed", listener);
-                        getLogger().error
-                            (sm.getString("standardContext.listenerStop",
-                                listeners[j].getClass().getName()), t);
+                        getLogger().error(
+                                sm.getString("standardContext.listenerStop", listeners[j].getClass().getName()), t);
                         ok = false;
                     }
                 }
@@ -4823,9 +4553,8 @@ public class StandardContext extends ContainerBase
                 } catch (Throwable t) {
                     t = ExceptionUtils.unwrapInvocationTargetException(t);
                     ExceptionUtils.handleThrowable(t);
-                    getLogger().error
-                       (sm.getString("standardContext.listenerStop",
-                            listeners[j].getClass().getName()), t);
+                    getLogger().error(sm.getString("standardContext.listenerStop", listeners[j].getClass().getName()),
+                            t);
                     ok = false;
                 }
             }
@@ -4846,9 +4575,8 @@ public class StandardContext extends ContainerBase
                 } catch (Throwable t) {
                     t = ExceptionUtils.unwrapInvocationTargetException(t);
                     ExceptionUtils.handleThrowable(t);
-                    getLogger().error
-                        (sm.getString("standardContext.listenerStop",
-                            listeners[j].getClass().getName()), t);
+                    getLogger().error(sm.getString("standardContext.listenerStop", listeners[j].getClass().getName()),
+                            t);
                     ok = false;
                 }
             }
@@ -4866,6 +4594,7 @@ public class StandardContext extends ContainerBase
 
     /**
      * Allocate resources, including proxy.
+     *
      * @throws LifecycleException if a start error occurs
      */
     public void resourcesStart() throws LifecycleException {
@@ -4876,12 +4605,10 @@ public class StandardContext extends ContainerBase
             resources.start();
         }
 
-        if (effectiveMajorVersion >=3 && addWebinfClassesResources) {
-            WebResource webinfClassesResource = resources.getResource(
-                    "/WEB-INF/classes/META-INF/resources");
+        if (effectiveMajorVersion >= 3 && addWebinfClassesResources) {
+            WebResource webinfClassesResource = resources.getResource("/WEB-INF/classes/META-INF/resources");
             if (webinfClassesResource.isDirectory()) {
-                getResources().createWebResourceSet(
-                        WebResourceRoot.ResourceSetType.RESOURCE_JAR, "/",
+                getResources().createWebResourceSet(WebResourceRoot.ResourceSetType.RESOURCE_JAR, "/",
                         webinfClassesResource.getURL(), "/");
             }
         }
@@ -4890,6 +4617,7 @@ public class StandardContext extends ContainerBase
 
     /**
      * Deallocate resources and destroy proxy.
+     *
      * @return <code>true</code> if no error occurred
      */
     public boolean resourcesStop() {
@@ -4915,11 +4643,11 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Load and initialize all servlets marked "load on startup" in the
-     * web application deployment descriptor.
+     * Load and initialize all servlets marked "load on startup" in the web application deployment descriptor.
+     *
+     * @param children Array of wrappers for all currently defined servlets (including those not declared load on
+     *                     startup)
      *
-     * @param children Array of wrappers for all currently defined
-     *  servlets (including those not declared load on startup)
      * @return <code>true</code> if load on startup was considered successful
      */
     public boolean loadOnStartup(Container children[]) {
@@ -4947,13 +4675,14 @@ public class StandardContext extends ContainerBase
                 try {
                     wrapper.load();
                 } catch (ServletException e) {
-                    getLogger().error(sm.getString("standardContext.loadOnStartup.loadException",
-                          getName(), wrapper.getName()), StandardWrapper.getRootCause(e));
+                    getLogger().error(
+                            sm.getString("standardContext.loadOnStartup.loadException", getName(), wrapper.getName()),
+                            StandardWrapper.getRootCause(e));
                     // NOTE: load errors (including a servlet that throws
                     // UnavailableException from the init() method) are NOT
                     // fatal to application startup
                     // unless failCtxIfServletStartFails="true" is specified
-                    if(getComputedFailCtxIfServletStartFails()) {
+                    if (getComputedFailCtxIfServletStartFails()) {
                         return false;
                     }
                 }
@@ -4965,23 +4694,23 @@ public class StandardContext extends ContainerBase
 
 
     /**
-     * Start this component and implement the requirements
-     * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
+     * Start this component and implement the requirements of
+     * {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
      *
-     * @exception LifecycleException if this component detects a fatal error
-     *  that prevents this component from being used
+     * @exception LifecycleException if this component detects a fatal error that prevents this component from being
+     *                                   used
      */
     @Override
     protected synchronized void startInternal() throws LifecycleException {
 
-        if(log.isDebugEnabled()) {
+        if (log.isDebugEnabled()) {
             log.debug("Starting " + getBaseName());
         }
 
         // Send j2ee.state.starting notification
         if (this.getObjectName() != null) {
-            Notification notification = new Notification("j2ee.state.starting",
-                    this.getObjectName(), sequenceNumber.getAndIncrement());
+            Notification notification = new Notification("j2ee.state.starting", this.getObjectName(),
+                    sequenceNumber.getAndIncrement());
             broadcaster.sendNotification(notification);
         }
 
@@ -4998,7 +4727,7 @@ public class StandardContext extends ContainerBase
         postWorkDirectory();
 
         // Add missing components as necessary
-        if (getResources() == null) {   // (1) Required by Loader
+        if (getResources() == null) { // (1) Required by Loader
             if (log.isDebugEnabled()) {
                 log.debug("Configuring default Resources");
             }
@@ -5031,8 +4760,7 @@ public class StandardContext extends ContainerBase
         // Validate required extensions
         boolean dependencyCheck = true;
         try {
-            dependencyCheck = ExtensionValidator.validateApplication
-                (getResources(), this);
+            dependencyCheck = ExtensionValidator.validateApplication(getResources(), this);
         } catch (IOException ioe) {
             log.error(sm.getString("standardContext.extensionValidationError"), ioe);
             dependencyCheck = false;
@@ -5045,8 +4773,7 @@ public class StandardContext extends ContainerBase
 
         // Reading the "catalina.useNaming" environment variable
         String useNamingProperty = System.getProperty("catalina.useNaming");
-        if ((useNamingProperty != null)
-            && (useNamingProperty.equals("false"))) {
+        if ((useNamingProperty != null) && (useNamingProperty.equals("false"))) {
             useNaming = false;
         }
 
@@ -5112,7 +4839,8 @@ public class StandardContext extends ContainerBase
                     CredentialHandler safeHandler = new CredentialHandler() {
                         @Override
                         public boolean matches(String inputCredentials, String storedCredentials) {
-                            return getRealmInternal().getCredentialHandler().matches(inputCredentials, storedCredentials);
+                            return getRealmInternal().getCredentialHandler().matches(inputCredentials,
+                                    storedCredentials);
                         }
 
                         @Override
@@ -5145,8 +4873,7 @@ public class StandardContext extends ContainerBase
                 if (manager == null) {
                     if (log.isDebugEnabled()) {
                         log.debug(sm.getString("standardContext.cluster.noManager",
-                                Boolean.valueOf((getCluster() != null)),
-                                Boolean.valueOf(distributable)));
+                                Boolean.valueOf((getCluster() != null)), Boolean.valueOf(distributable)));
                     }
                     if ((getCluster() != null) && distributable) {
                         try {
@@ -5163,15 +4890,14 @@ public class StandardContext extends ContainerBase
                 // Configure default manager if none was specified
                 if (contextManager != null) {
                     if (log.isDebugEnabled()) {
-                        log.debug(sm.getString("standardContext.manager",
-                                contextManager.getClass().getName()));
+                        log.debug(sm.getString("standardContext.manager", contextManager.getClass().getName()));
                     }
                     setManager(contextManager);
                 }
 
-                if (manager!=null && (getCluster() != null) && distributable) {
-                    //let the cluster know that there is a context that is distributable
-                    //and that it has its own manager
+                if (manager != null && (getCluster() != null) && distributable) {
+                    // let the cluster know that there is a context that is distributable
+                    // and that it has its own manager
                     getCluster().registerManager(manager);
                 }
             }
@@ -5183,8 +4909,7 @@ public class StandardContext extends ContainerBase
 
             // We put the resources into the servlet context
             if (ok) {
-                getServletContext().setAttribute
-                    (Globals.RESOURCES_ATTR, getResources());
+                getServletContext().setAttribute(Globals.RESOURCES_ATTR, getResources());
 
                 if (getInstanceManager() == null) {
                     javax.naming.Context context = null;
@@ -5192,17 +4917,15 @@ public class StandardContext extends ContainerBase
                         context = getNamingContextListener().getEnvContext();
                     }
                     Map<String, Map<String, String>> injectionMap = buildInjectionMap(
-                            getIgnoreAnnotations() ? new NamingResourcesImpl(): getNamingResources());
-                    setInstanceManager(new DefaultInstanceManager(context,
-                            injectionMap, this, this.getClass().getClassLoader()));
+                            getIgnoreAnnotations() ? new NamingResourcesImpl() : getNamingResources());
+                    setInstanceManager(
+                            new DefaultInstanceManager(context, injectionMap, this, this.getClass().getClassLoader()));
                 }
-                getServletContext().setAttribute(
-                        InstanceManager.class.getName(), getInstanceManager());
+                getServletContext().setAttribute(InstanceManager.class.getName(), getInstanceManager());
                 InstanceManagerBindings.bind(getLoader().getClassLoader(), getInstanceManager());
 
                 // Create context attributes that will be required
-                getServletContext().setAttribute(
-                        JarScanner.class.getName(), getJarScanner());
+                getServletContext().setAttribute(JarScanner.class.getName(), getJarScanner());
 
                 // Make the version info available
                 getServletContext().setAttribute(Globals.WEBAPP_VERSION, getWebappVersion());
@@ -5212,11 +4935,9 @@ public class StandardContext extends ContainerBase
             mergeParameters();
 
             // Call ServletContainerInitializers
-            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry :
-                initializers.entrySet()) {
+            for (Map.Entry<ServletContainerInitializer, Set<Class<?>>> entry : initializers.entrySet()) {
                 try {
-                    entry.getKey().onStartup(entry.getValue(),
-                            getServletContext());
+                    entry.getKey().onStartup(entry.getValue(), getServletContext());
                 } catch (ServletException e) {
                     log.error(sm.getString("standardContext.sciFail"), e);
                     ok = false;
@@ -5245,7 +4966,7 @@ public class StandardContext extends ContainerBase
                 if (manager instanceof Lifecycle) {
                     ((Lifecycle) manager).start();
                 }
-            } catch(Exception e) {
+            } catch (Exception e) {
                 log.error(sm.getString("standardContext.managerFail"), e);
                 ok = false;
             }
@@ -5260,7 +4981,7 @@ public class StandardContext extends ContainerBase
 
             // Load and initialize all "load on startup" servlets
             if (ok) {
-                if (!loadOnStartup(findChildren())){
+                if (!loadOnStartup(findChildren())) {
                     log.error(sm.getString("standardContext.servletFail"));
                     ok = false;
                 }
@@ -5282,13 +5003,12 @@ public class StandardContext extends ContainerBase
             log.error(sm.getString("standardContext.startFailed", getName()));
         }
 
-        startTime=System.currentTimeMillis();
+        startTime = System.currentTimeMillis();
 
         // Send j2ee.state.running notification
         if (ok && (this.getObjectName() != null)) {
-            Notification notification =
-                new Notification("j2ee.state.running", this.getObjectName(),
-                                 sequenceNumber.getAndIncrement());
+            Notification notification = new Notification("j2ee.state.running", this.getObjectName(),
+                    sequenceNumber.getAndIncrement());
             broadcaster.sendNotification(notification);
         }
 
@@ -5303,8 +5023,8 @@ public class StandardContext extends ContainerBase
             setState(LifecycleState.FAILED);
             // Send j2ee.object.failed notification
             if (this.getObjectName() != null) {
-                Notification notification = new Notification("j2ee.object.failed",
-                        this.getObjectName(), sequenceNumber.getAndIncrement());
+                Notification notification = new Notification("j2ee.object.failed", this.getObjectName(),
+                        sequenceNumber.getAndIncrement());
                 broadcaster.sendNotification(notification);
             }
         } else {
@@ -5313,11 +5033,9 @@ public class StandardContext extends ContainerBase
     }
 
 
-    private void checkConstraintsForUncoveredMethods(
-            SecurityConstraint[] constraints) {
-        SecurityConstraint[] newConstraints =
-                SecurityConstraint.findUncoveredHttpMethods(constraints,
-                        getDenyUncoveredHttpMethods(), getLogger());
+    private void checkConstraintsForUncoveredMethods(SecurityConstraint[] constraints) {
+        SecurityConstraint[] newConstraints = SecurityConstraint.findUncoveredHttpMethods(constraints,
+                getDenyUncoveredHttpMethods(), getLogger());
         for (SecurityConstraint constraint : newConstraints) {
             addConstraint(constraint);
         }
@@ -5326,25 +5044,25 @@ public class StandardContext extends ContainerBase
 
     private Map<String, Map<String, String>> buildInjectionMap(NamingResourcesImpl namingResources) {
         Map<String, Map<String, String>> injectionMap = new HashMap<>();
-        for (Injectable resource: namingResources.findLocalEjbs()) {
+        for (Injectable resource : namingResources.findLocalEjbs()) {
             addInjectionTarget(resource, injectionMap);
         }
-        for (Injectable resource: namingResources.findEjbs()) {
+        for (Injectable resource : namingResources.findEjbs()) {
... 4276 lines suppressed ...


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org