db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r681670 - in /db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services: daemon/SingleThreadDaemonFactory.java monitor/BaseMonitor.java
Date Fri, 01 Aug 2008 12:21:21 GMT
Author: kmarsden
Date: Fri Aug  1 05:21:21 2008
New Revision: 681670

URL: http://svn.apache.org/viewvc?rev=681670&view=rev
Log:
DERBY-3803 org.apache.derbyTesting.functionTests.tests.lang.XMLTypeAndOpsTest' failures on
JVM 1.5 on trunk, 10.4 and 10.3


Modified:
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java
    db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java?rev=681670&r1=681669&r2=681670&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java
Fri Aug  1 05:21:21 2008
@@ -26,6 +26,7 @@
 import org.apache.derby.iapi.services.daemon.DaemonService;
 import org.apache.derby.impl.services.daemon.BasicDaemon;
 import org.apache.derby.iapi.services.monitor.Monitor;
+import org.apache.derby.iapi.util.PrivilegedThreadOps;
 
 public class SingleThreadDaemonFactory implements DaemonFactory
 {
@@ -46,6 +47,12 @@
 		BasicDaemon daemon = new BasicDaemon(contextService);
 
 		Thread daemonThread = Monitor.getMonitor().getDaemonThread(daemon, name, false);
+		// DERBY-3745.  setContextClassLoader for thread to null to avoid
+		// leaking class loaders.
+		PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
+							  daemonThread, null);
+
+
 		daemonThread.start();
 		return daemon;
 	}

Modified: db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java?rev=681670&r1=681669&r2=681670&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
(original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
Fri Aug  1 05:21:21 2008
@@ -276,6 +276,11 @@
 		dontGC = new AntiGC(keepItems);
 
 		Thread dontGCthread = getDaemonThread(dontGC, "antiGC", true);
+		// DERBY-3745.  setContextClassLoader for thread to null to avoid
+		// leaking class loaders.
+		PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
+						dontGCthread, null);
+
 		dontGCthread.start();
 
 		if (SanityManager.DEBUG) {
@@ -2079,28 +2084,7 @@
 	}
 
 	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);
-
 		t.setDaemon(true);
 
 		if (setMinPriority) {



Mime
View raw message