shiro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "david e. berry (JIRA)" <j...@apache.org>
Subject [jira] Commented: (SHIRO-159) ThreadLocal is not cleared upon the unloading of the webapp and the SHiro Servlet
Date Fri, 14 May 2010 10:45:43 GMT

    [ https://issues.apache.org/jira/browse/SHIRO-159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12867470#action_12867470
] 

david e. berry commented on SHIRO-159:
--------------------------------------

Thanks for all the immediate attention to this. I will do a build and let you know what I
find. I use getSubject all over the place, but they should all as a part of a web request.

Some Comments:

In looking through the code, you unbind, by emptying the values out of the HashMap that you
have stored as a ThreadLocal variable. 

I could not find where you actually remove the HashMap from the ThreadLocal with a call to
resources.remove().

The messages I posted from Tomcat is complaining about the HashMap that is stored in ThreadLocal:

SEVERE: A web application created a ThreadLocal with key of type [null] (value [org.apache.shiro.util.ThreadContext$1@c0c66a])
and a value of type [java.util.HashMap] (value [{}]) but failed to remove it when the web
application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.


Perhaps there should be a release method on ThreadContext like this:

    public static void release() {
			// clear the map
                        resources.get().clear();
			// clear the ThreadLocal()
			resources.remove();
			// clear the reference to the ThreadLocal
			resources=null;
    }

and then call it in AbstractFilter.destroy()

    public void destroy() {
			ThreadContext.release();
    }

I am going to test your changes first. If that does not clear it up I will give the above
a try as well.


> ThreadLocal is not cleared upon the unloading of the webapp and the SHiro Servlet
> ---------------------------------------------------------------------------------
>
>                 Key: SHIRO-159
>                 URL: https://issues.apache.org/jira/browse/SHIRO-159
>             Project: Shiro
>          Issue Type: Bug
>          Components: Integration: JEE
>    Affects Versions: 1.0.0
>         Environment:  Model Name:	MacBook Pro
>   Model Identifier:	MacBookPro5,1
>   Processor Name:	Intel Core 2 Duo
>   Processor Speed:	2.8 GHz
>   Number Of Processors:	1
>   Total Number Of Cores:	2
>   L2 Cache:	6 MB
>   Memory:	4 GB
>   Bus Speed:	1.07 GHz
>  System Version:	Mac OS X 10.6.3 (10D573)
>   Kernel Version:	Darwin 10.3.0
>  
>            Reporter: david e. berry
>             Fix For: 1.0.0
>
>
> Tomcat 6.0.26 reports a severe error when unloading a web app that uses org.apache.shiro.web.servlet.IniShiroFilter
> SEVERE: A web application created a ThreadLocal with key of type [null] (value [org.apache.shiro.util.ThreadContext$1@c0c66a])
and a value of type [java.util.HashMap] (value [{}]) but failed to remove it when the web
application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
> May 13, 2010 9:29:51 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message