[jboss-jira] [JBoss JIRA] (AS7-3732) sun.net.www.http.KeepAliveCache preventing classloader from being garbage collected
Philippe Guinot (JIRA)
jira-events at lists.jboss.org
Mon Feb 13 08:38:02 EST 2012
Philippe Guinot created AS7-3732:
------------------------------------
Summary: 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
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: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list