hg: jdk7/tl/jdk: 7008595: Class loader leak caused by keepAliveTimer thread in KeepAliveCache

Chris Hegarty chris.hegarty at oracle.com
Thu Feb 3 18:32:09 UTC 2011


On 02/ 3/11 05:56 PM, Jason Mehrens wrote:
> I understand why the previous code leaks but, why is a null value safe
> to use for the CCL? Is it because this code is part of the JDK (not ext
> classloader) or is it because no more class loading is done on that

These are internal JDK implementation threads that are used to control 
the lifetime of persistent HTTP connections. The threads will only 
trigger loading of sun private classes, they will never have to load any 
application classes, so it is safe to set the CCL to null.

> thread? For 3rd party libs, should the CCL be set to null or set to the
> classloader of the thread's target and in the case of thread subclasses
> the loader of the subclass thread?

It depends on the libs, for example 
java.util.ServiceLoader.load(Class<S> service) is specified to use the 
current thread's context class loader. It is really up to the implemenation.

-Chris.

>
> Thanks,
>
> Jason
>
>
>  > From: chris.hegarty at oracle.com
>  > To: jdk7-changes at openjdk.java.net; compiler-dev at openjdk.java.net;
> core-libs-dev at openjdk.java.net; serviceability-dev at openjdk.java.net;
> security-dev at openjdk.java.net; net-dev at openjdk.java.net
>  > Subject: hg: jdk7/tl/jdk: 7008595: Class loader leak caused by
> keepAliveTimer thread in KeepAliveCache
>  > Date: Thu, 3 Feb 2011 10:11:03 +0000
>  >
>  > Changeset: 3c86f24f7500
>  > Author: chegar
>  > Date: 2011-02-03 10:10 +0000
>  > URL: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/3c86f24f7500
>  >
>  > 7008595: Class loader leak caused by keepAliveTimer thread in
> KeepAliveCache
>  > Reviewed-by: michaelm
>  >
>  > ! src/share/classes/sun/net/www/http/KeepAliveCache.java
>  > ! src/share/classes/sun/net/www/http/KeepAliveStream.java
>  >



More information about the core-libs-dev mailing list