8156824: com.sun.jndi.ldap.pool.PoolCleaner should clear its context class loader
Reviewed-by: alanb, dfuchs
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapPoolManager.java Thu Jul 28 19:34:58 2016 +0530
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/LdapPoolManager.java Thu Jul 28 16:15:51 2016 +0100
@@ -39,6 +39,7 @@
import com.sun.jndi.ldap.pool.PoolCleaner;
import com.sun.jndi.ldap.pool.Pool;
+import jdk.internal.misc.InnocuousThread;
/**
* Contains utilities for managing connection pools of LdapClient.
@@ -163,7 +164,17 @@
if (idleTimeout > 0) {
// Create cleaner to expire idle connections
- new PoolCleaner(idleTimeout, pools).start();
+ PrivilegedAction<Void> pa = new PrivilegedAction<Void>() {
+ public Void run() {
+ Thread t = InnocuousThread.newSystemThread(
+ "LDAP PoolCleaner",
+ new PoolCleaner(idleTimeout, pools));
+ assert t.getContextClassLoader() == null;
+ t.setDaemon(true);
+ t.start();
+ return null;
+ }};
+ AccessController.doPrivileged(pa);
}
if (debug) {
--- a/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/pool/PoolCleaner.java Thu Jul 28 19:34:58 2016 +0530
+++ b/jdk/src/java.naming/share/classes/com/sun/jndi/ldap/pool/PoolCleaner.java Thu Jul 28 16:15:51 2016 +0100
@@ -30,7 +30,7 @@
*
* @author Rosanna Lee
*/
-final public class PoolCleaner extends Thread {
+final public class PoolCleaner implements Runnable {
final private Pool[] pools;
final private long period;
@@ -42,9 +42,9 @@
super();
this.period = period;
this.pools = pools.clone();
- setDaemon(true);
}
+ @Override
public void run() {
long threshold;
while (true) {