db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r679620 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
Date Fri, 25 Jul 2008 00:03:03 GMT
Author: kmarsden
Date: Thu Jul 24 17:03:03 2008
New Revision: 679620

URL: http://svn.apache.org/viewvc?rev=679620&view=rev
Log:
DERBY-3745 Derby can leak classloaders in an app server environment
Cleanup change to set context class loader for newly created threads 
directly rather than setting the context classloader of the current 
thread before creation.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java?rev=679620&r1=679619&r2=679620&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
Thu Jul 24 17:03:03 2008
@@ -2079,27 +2079,11 @@
 	}
 
 	public Thread getDaemonThread(Runnable task, String name, boolean setMinPriority) {
-		// DERBY-3745 We want to avoid the thread leaking class loaders,
-		// so we make the context class loader null before we create the
-		// thread.
-		ClassLoader savecl = null;
-		boolean hasGetClassLoaderPerms = false;
-		try {
-			savecl = PrivilegedThreadOps.getContextClassLoader(Thread.currentThread());
-			hasGetClassLoaderPerms = true;
-		}  catch (SecurityException se) {
-			// ignore security exception. Earlier versions of Derby, before
-			// the DERBY-3745 fix did not require getClassLoader permissions.
-			// We may leak class loaders if we are not able to get the 
-			// class loader, but we cannot just fail.
-		}
-		if (hasGetClassLoaderPerms)
-			PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
-								 Thread.currentThread(), null);
 		Thread t =  new Thread(daemonGroup, task, "derby.".concat(name));
-		if (hasGetClassLoaderPerms)
-			PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
-							  Thread.currentThread(), savecl);
+		// DERBY-3745.  setContextClassLoader for thread to null to avoid
+		// leaking class loaders.
+		PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
+							  t, null);
 
 		t.setDaemon(true);
 



Mime
View raw message