tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: iCal4j and ThreadLocal
Date Wed, 01 Sep 2010 14:54:50 GMT
Hash: SHA1


On 8/31/2010 4:49 PM, Bill Davidson wrote:
> On 8/31/2010 12:16 PM, Christopher Schultz wrote:
>> Or, just remove the ThreadLocal manually. Since you know it's name, it
>> should be easy to remove. There are two obvious ways to remove these
>> ThreadLocals in a webapp:
>> 1. Modify all the code that uses the iCal4j library so that, after
>> performing it's iCal4j operations, you manually remove the ThreadLocals.
> I don't understand how to do that.  I have local objects that I create from
> the library.  Once I'm done with them, they go out of scope and are given
> to the garbage collector.  However, the ThreadLocal's are static to the
> class, and the library offers no way to access them.  Is there some way to
> find them?
> Hmm, now that I think about it, Tomcat found them.  I guess I should
> look at the Tomcat source.

The most convenient thing would be for the library author to provide a
"cleanup" method. Tomcat uses reflective tricks to probe the ThreadLocal
map and purge it.

>> 2. Write a Filter that removes any ThreadLocals once the request has
>> been completed.
> Again, I'm not sure how to do that.

Once you figure out how to do the above, writing a Filter is simple:
just implement the javax.servlet.Filter interface and configure your
class in web.xml. Your "doFilter" method just includes whatever code
works above.

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message