Bug 55582 - Concurrent issue of TagFileProcessor
Summary: Concurrent issue of TagFileProcessor
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: trunk
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-22 10:00 UTC by Sheldon Shao
Modified: 2014-06-20 05:24 UTC (History)
1 user (show)



Attachments
Unsynchronized getting wrapper from RuntimeContext (811 bytes, patch)
2013-09-22 10:00 UTC, Sheldon Shao
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sheldon Shao 2013-09-22 10:00:36 UTC
Created attachment 30871 [details]
Unsynchronized getting wrapper from RuntimeContext

The following code has concurrent issue.

        JspRuntimeContext rctxt = ctxt.getRuntimeContext();
        JspServletWrapper wrapper = rctxt.getWrapper(wrapperUri);

        synchronized (rctxt) {
            if (wrapper == null) {

               ....
It creates duplicated JspServletWrapper in this scenario,

A.jsp --> C.tag
B.jsp --> C.tag

A.jsp and B.jsp are both compiling and come to the given lines.
Two threads all get null from JspRuntimeContext(JspServletWrapper == null).
So two instances of JspServletWrapper was created.
Comment 1 Sheldon Shao 2013-09-22 10:01:10 UTC
Comment on attachment 30871 [details]
Unsynchronized getting wrapper from RuntimeContext

>Index: java/org/apache/jasper/compiler/TagFileProcessor.java
>===================================================================
>--- java/org/apache/jasper/compiler/TagFileProcessor.java	(revision 1507186)
>+++ java/org/apache/jasper/compiler/TagFileProcessor.java	(working copy)
>@@ -533,9 +533,11 @@
> 
>         JspCompilationContext ctxt = compiler.getCompilationContext();
>         JspRuntimeContext rctxt = ctxt.getRuntimeContext();
>-        JspServletWrapper wrapper = rctxt.getWrapper(wrapperUri);
>+        
> 
>         synchronized (rctxt) {
>+        	JspServletWrapper wrapper = rctxt.getWrapper(wrapperUri);
>+        	
>             if (wrapper == null) {
>                 wrapper = new JspServletWrapper(ctxt.getServletContext(), ctxt
>                         .getOptions(), tagFilePath, tagInfo, ctxt
Comment 2 Mark Thomas 2013-09-23 13:57:43 UTC
Thanks for the report. This has been fixed in 8.0.x (for 8.0.0-RC4 onwards) and 7.0.x (for 7.0.44 onwards).