Bug 38899 - Problem with TagHandlerPool.reuse(Tag) method
Summary: Problem with TagHandlerPool.reuse(Tag) method
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.5.15
Hardware: Other other
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-08 21:04 UTC by Peter Fassev
Modified: 2006-03-08 13:12 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Fassev 2006-03-08 21:04:02 UTC
Currently the method org.apache.jasper.runtime.TagHandlerPool.reuse(Tag 
handler) - subproject jasper - has the following implementation:

    public void reuse(Tag handler) {
        synchronized( this ) {
            if (current < (handlers.length - 1)) {
                handlers[++current] = handler;
                return;
            }
        }
        // There is no need for other threads to wait for us to release
        handler.release();
    }

Where the handler.release() method of the returned TAG is called after the tag 
is returned to the pool and outside of the synchronization block. This is 
obviously wrong, because another thread can obtain the same tag from the pool 
and start use it, where at the same time the TagHandlerPool will release the 
tag (i.e. the tag will free its internal properties)! On a highly frequented 
site, this is very likely to happen simutaniously and the state of the tag will 
be inconsistent.

The solution is very simple: Call the handler.release() Method before the tag 
is returned to the pool, or synchronize it.

Regards
Peter
Comment 1 Peter Fassev 2006-03-08 21:12:27 UTC
Sorry, I am blind and I jumped the gut too fast! The tag is released, ony when 
it is not added to the pool. So this bug is invalid.