]
Remy Maucherat resolved AS7-3732.
---------------------------------
Resolution: Won't Fix
You are allowed to use container lifecycle listeners in your webapp as needed, so you may
use any listener needed to clanup after your application.
sun.net.www.http.KeepAliveCache preventing classloader from being
garbage collected
-----------------------------------------------------------------------------------
Key: AS7-3732
URL:
https://issues.jboss.org/browse/AS7-3732
Project: Application Server 7
Issue Type: Bug
Components: Web
Affects Versions: 7.1.0.CR1b
Environment: AS 7 running on JDK 1.6.0_30, Windows 7
Reporter: Philippe Guinot
Assignee: Remy Maucherat
Labels: as7, classloader, httpclient, jboss, keepalivecache, leak,
urlconnection
This is related to Tomcat issue 49230:
https://issues.apache.org/bugzilla/show_bug.cgi?id=49230
{quote}When a servlet creates a URLConnection, internally this is done us-ing
sun.net.www.http.HttpClient. To have the ability to keep connections alive and
close them after a certain time they are placed inside a cache. A static
reference is kept to this cache (sun.net.www.http.KeepAliveCache).{quote}
This cache contains a non-final reference to a Thread which keeps a reference to the
Application's ClassLoader, hence a Class Loader leak.
The Tomcat patch won't work because the reference to the Thread is non-final and so a
new thread maybe created during the application's lifecycle, far after the startup.
I don't have any solution to this issue, I'm afraid. The only workaround I've
found is to run this code during the shutdown of my application. This is very ugly
though:
{code}
final KeepAliveCache keepAliveCache = new HttpClient() {
public KeepAliveCache getKeepAliveCache() {
return kac;
}
}.getKeepAliveCache();
final Field f = KeepAliveCache.class.getDeclaredField("keepAliveTimer");
f.setAccessible(true);
f.set(keepAliveCache, null);
{code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: