Bug 62662 - Multithreaded JSP compilation generates invalid web.xml
Summary: Multithreaded JSP compilation generates invalid web.xml
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 8.5.33
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 62677 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-08-30 14:52 UTC by Bernhard Frauendienst
Modified: 2018-09-05 08:38 UTC (History)
1 user (show)



Attachments
Patch to synchronize multi-threaded access to output streams (2.34 KB, patch)
2018-08-30 16:12 UTC, Bernhard Frauendienst
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Frauendienst 2018-08-30 14:52:24 UTC
The multi-threaded JSP compilation introduced in 8.5.33 with Bug 53492 can create race conditions that lead to invalid web.xml (fragments) to be generated. 

Since access of output streams in `generateWebMapping` is not thread-safe, this can cause mappings to be interleaved, like in this (real-life) example:


>    <servlet-mapping>
>        <servlet-name>org.apache.jsp.WEB_002dINF.jsp.admin.seoKeywordsCmsTable_jsp
>    <servlet-mapping>
>        <servlet-name></servlet-name>
>        <url-pattern>org.apache.jsp.WEB_002dINF.jsp.admin.seo.seokeywordtable_jsp</servlet-name>
>        <url-pattern>/WEB-INF/jsp/admin/seo/seoKeywordsCmsTable.jsp/WEB-INF/jsp/admin/seo/seokeywordtable.jsp</url-pattern>
>    </servlet-mapping>
></url-pattern>
>    </servlet-mapping>

Obviously, this causes an error on startup.
Comment 1 Bernhard Frauendienst 2018-08-30 16:12:32 UTC
Created attachment 36122 [details]
Patch to synchronize multi-threaded access to output streams

Attached patch should be sufficient to prevent chunks getting mixed up.
Comment 2 Mark Thomas 2018-08-31 10:06:10 UTC
Thanks for the patch.

Fixed in:
- trunk for 9.0.12 onwards
- 8.5.x for 8.5.34 onwards
- 7.0.x for 7.0.91 onwards
Comment 3 Mark Thomas 2018-09-05 08:38:56 UTC
*** Bug 62677 has been marked as a duplicate of this bug. ***