7008595: Class loader leak caused by keepAliveTimer thread in KeepAliveCache
authorchegar
Thu, 03 Feb 2011 10:10:11 +0000
changeset 8167 7599e778785f
parent 8166 13423c0952ad
child 8168 fd0dd3dc997d
7008595: Class loader leak caused by keepAliveTimer thread in KeepAliveCache Reviewed-by: michaelm
jdk/src/share/classes/sun/net/www/http/KeepAliveCache.java
jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java
--- a/jdk/src/share/classes/sun/net/www/http/KeepAliveCache.java	Wed Feb 02 13:13:34 2011 -0500
+++ b/jdk/src/share/classes/sun/net/www/http/KeepAliveCache.java	Thu Feb 03 10:10:11 2011 +0000
@@ -106,6 +106,9 @@
                     keepAliveTimer = new Thread(grp, cache, "Keep-Alive-Timer");
                     keepAliveTimer.setDaemon(true);
                     keepAliveTimer.setPriority(Thread.MAX_PRIORITY - 2);
+                    // Set the context class loader to null in order to avoid
+                    // keeping a strong reference to an application classloader.
+                    keepAliveTimer.setContextClassLoader(null);
                     keepAliveTimer.start();
                     return null;
                 }
--- a/jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java	Wed Feb 02 13:13:34 2011 -0500
+++ b/jdk/src/share/classes/sun/net/www/http/KeepAliveStream.java	Thu Feb 03 10:10:11 2011 +0000
@@ -185,6 +185,9 @@
                         cleanerThread = new Thread(grp, queue, "Keep-Alive-SocketCleaner");
                         cleanerThread.setDaemon(true);
                         cleanerThread.setPriority(Thread.MAX_PRIORITY - 2);
+                        // Set the context class loader to null in order to avoid
+                        // keeping a strong reference to an application classloader.
+                        cleanerThread.setContextClassLoader(null);
                         cleanerThread.start();
                         return null;
                     }