Bug 57809 - Don't store merged web.xml
Summary: Don't store merged web.xml
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.x-trunk
Hardware: PC Mac OS X 10.1
: P2 enhancement (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-13 17:07 UTC by Philippe Marschall
Modified: 2016-02-19 19:09 UTC (History)
0 users



Attachments
simple patch (1.49 KB, patch)
2015-04-13 17:07 UTC, Philippe Marschall
Details | Diff
2nd try at a patch (1.50 KB, patch)
2015-04-19 18:17 UTC, Philippe Marschall
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Marschall 2015-04-13 17:07:37 UTC
Created attachment 32647 [details]
simple patch

I analyzed several heap dumps to find out why for small applications Tomcat uses more memory than Jetty. Some of this seems to come from the fact that for ever web application a merged web.xml is stored in memory. A comment in ContextConfig suggests that this was once necessary for Jasper but it looks as if the relevant TODO has been fixed by now.

On a default Tomcat with the default applications this saves about 1MB.
Comment 1 Remy Maucherat 2015-04-13 17:15:48 UTC
The constant doesn't look like it is used, but this may not be such a good idea. I'll leave the BZ open for further review.
Comment 2 Konstantin Kolinko 2015-04-14 00:59:11 UTC
In Tomcat 7 the MERGED_WEB_XML ("org.apache.tomcat.util.scan.MergedWebXml") attribute is used to pass web application configuration to Jasper.

In Tomcat 8 it is unused, but it is used by Tomcat test cases (TestWebXml). Your "simple patch" will break the tests.

In theory, there can be 3rd party code that uses this feature.


http://markmail.org/message/hqnuyvikofmfcbl2
"Offline generation of effective web.xml" thread on 2012-09,
one of first discussions of this issue.
Comment 3 Philippe Marschall 2015-04-14 05:30:07 UTC
Which part of TestWebXml does it break? The test compiles and 19/19 tests are green.
Comment 4 Remy Maucherat 2015-04-14 09:07:11 UTC
I think this can be useful for debugging and monitoring (management interfaces like this kind of stuff), but since this is a String it is probably not that useful for apps.

testWebXml mentions it but doesn't actually test it.
Comment 5 Philippe Marschall 2015-04-15 05:38:02 UTC
The flag to log the merged web.xml is still in there.
Comment 6 Philippe Marschall 2015-04-19 18:17:28 UTC
Created attachment 32661 [details]
2nd try at a patch

Updated patch:
- keeps the constant but marks it as deprecated
- keeps the switch to log the merged web.xml for debugging
Comment 7 Mark Thomas 2016-02-19 19:09:32 UTC
Thanks for the patch. I'd forgotten about this issue until after I had already fixed the code buy my approach was broadly similar.

The constant for the attribute name has been deprecated in 8.0.x and the constant and the use of it has been removed in 9.0.x.