[
https://issues.jboss.org/browse/WELD-787?page=com.atlassian.jira.plugin.s...
]
Aslak Knutsen commented on WELD-787:
------------------------------------
Any of the current weld-servlet-test-tomcat test cases should do to trigger the issue.
The problem is that Tomcats WebappClassLoader, which is the class that clears the
ThreadLocals, will only clear the local variables if the key or value is loaded by the
WebappClassLoader.
In the weld-servlet-test-tomcat setup, Weld Servlet is loaded by AppCL, not the
WebappClassLoader, so no leak is reported.
If you breakpoint: WebappClassloader.clearReferencesThreadLocals and loop until it handles
Thread[http-127.0.0.1-8888-1,5,main]. you will see in
WebappClassloader.clearThreadLocalMap that the variable CurrentInjectionPoint is ignored
since it's not loaded by this(ClassLoader),
To trigger the leak with warning, any full War the bundles Weld-Servlet deployed on tomcat
should do the trix.
CurrentInjectionPoint ThreadLocal leak with Weld Servlet
--------------------------------------------------------
Key: WELD-787
URL:
https://issues.jboss.org/browse/WELD-787
Project: Weld
Issue Type: Bug
Components: Servlet Container Support
Affects Versions: 1.1.0.Beta2
Environment: Weld Servlet 1.1.0-SNAPSHOT / Beta2 / Beta1 on Tomcat 6
Reporter: Aslak Knutsen
Fix For: 1.2.0.Beta1
Nov 22, 2010 7:13:40 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [/active1] created a ThreadLocal with key of type [null]
(value [org.jboss.weld.injection.CurrentInjectionPoint$1@30b95f2]) and a value of type
[java.util.Stack] (value [[]]) but failed to remove it when the web application was
stopped. This is very likely to create a memory leak.
The CurrentInjectionPoint push/pop works, since the Stack object on the Thread is Empty
when undeploy.
CurrentInjectionPoint.cleanup is called during the contextDestroyed lifecycle, but the
event is executed on the main Thread, not the HTTP thread. This results in the Empty Stack
leak.
ThreadLocals active during a HTTP request has to be cleaned up at the end of the Request.
There are no guarantees that you will ever see that Thread again.
CurrentInjectionPoint.cleanup should probably be moved to the requestDestroyed lifecycle.
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira