Author: markt
Date: Fri Feb 19 10:23:42 2016
New Revision: 1731216

URL: http://svn.apache.org/viewvc?rev=1731216&view=rev
Log:
Refactor the web.xml parsing so a new parser is created every time the web 
application starts rather than creating and caching the parser when the Context 
is created. This enables the parser to take account of modified Context 
configuration parameters and reduces (slightly) the memory footprint of a 
running Tomcat instance.

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1731216&r1=1731215&r2=1731216&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Fri Feb 19 
10:23:42 2016
@@ -241,8 +241,6 @@ public class ContextConfig implements Li
      */
     protected boolean handlesTypesNonAnnotations = false;
 
-    private WebXmlParser webXmlParser;
-
 
     // ------------------------------------------------------------- Properties
 
@@ -741,9 +739,6 @@ public class ContextConfig implements Li
         ok = true;
 
         contextConfig(contextDigester);
-
-        webXmlParser = new WebXmlParser(context.getXmlNamespaceAware(),
-                context.getXmlValidation(), context.getXmlBlockExternal());
     }
 
 
@@ -1109,8 +1104,11 @@ public class ContextConfig implements Li
          *   those in JARs excluded from an absolute ordering) need to be
          *   scanned to check if they match.
          */
+        WebXmlParser webXmlParser = new 
WebXmlParser(context.getXmlNamespaceAware(),
+                context.getXmlValidation(), context.getXmlBlockExternal());
+
         Set<WebXml> defaults = new HashSet<>();
-        defaults.add(getDefaultWebXmlFragment());
+        defaults.add(getDefaultWebXmlFragment(webXmlParser));
 
         WebXml webXml = createWebXml();
 
@@ -1128,7 +1126,7 @@ public class ContextConfig implements Li
         // provided by the container. If any of the application JARs have a
         // web-fragment.xml it will be parsed at this point. web-fragment.xml
         // files are ignored for container provided JARs.
-        Map<String,WebXml> fragments = processJarsForWebFragments(webXml);
+        Map<String,WebXml> fragments = processJarsForWebFragments(webXml, 
webXmlParser);
 
         // Step 2. Order the fragments.
         Set<WebXml> orderedFragments = null;
@@ -1456,7 +1454,7 @@ public class ContextConfig implements Li
     }
 
 
-    private WebXml getDefaultWebXmlFragment() {
+    private WebXml getDefaultWebXmlFragment(WebXmlParser webXmlParser) {
 
         // Host should never be null
         Host host = (Host) context.getParent();
@@ -1877,9 +1875,11 @@ public class ContextConfig implements Li
      * known not contain fragments will be skipped.
      *
      * @param application The main web.xml metadata
+     * @param webXmlParser The parser to use to process the web.xml file
      * @return A map of JAR name to processed web fragment (if any)
      */
-    protected Map<String,WebXml> processJarsForWebFragments(WebXml 
application) {
+    protected Map<String,WebXml> processJarsForWebFragments(WebXml application,
+            WebXmlParser webXmlParser) {
 
         JarScanner jarScanner = context.getJarScanner();
         boolean delegate = false;

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1731216&r1=1731215&r2=1731216&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Feb 19 10:23:42 2016
@@ -92,6 +92,13 @@
         Refactor the JAR and JAR-in-WAR resource handling to reduce the memory
         footprint of the web application. (markt)
       </fix>
+      <fix>
+        Refactor the web.xml parsing so a new parser is created every time the
+        web application starts rather than creating and caching the parser when
+        the Context is created. This enables the parser to take account of
+        modified Context configuration parameters and reduces (slightly) the
+        memory footprint of a running Tomcat instance. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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

Reply via email to