db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r691364 - in /db/derby/code/branches/10.3/java/engine/org/apache/derby: iapi/util/ impl/services/daemon/ impl/services/monitor/ impl/services/timer/
Date Tue, 02 Sep 2008 20:16:54 GMT
Author: kmarsden
Date: Tue Sep  2 13:16:53 2008
New Revision: 691364

URL: http://svn.apache.org/viewvc?rev=691364&view=rev
Log:
DERBY-3745 

inline priv blocks instead of using utility methods.


Removed:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/util/PrivilegedThreadOps.java
Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java?rev=691364&r1=691363&r2=691364&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/daemon/SingleThreadDaemonFactory.java
Tue Sep  2 13:16:53 2008
@@ -21,12 +21,15 @@
 
 package org.apache.derby.impl.services.daemon;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 import org.apache.derby.iapi.services.context.ContextService;
 import org.apache.derby.iapi.services.daemon.DaemonFactory;
 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,11 +49,23 @@
 	{
 		BasicDaemon daemon = new BasicDaemon(contextService);
 
-		Thread daemonThread = Monitor.getMonitor().getDaemonThread(daemon, name, false);
+		final Thread daemonThread = Monitor.getMonitor().getDaemonThread(daemon, name, false);
 		// DERBY-3745.  setContextClassLoader for thread to null to avoid
 		// leaking class loaders.
-		PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
-							  daemonThread, null);
+		try {
+            AccessController.doPrivileged(
+             new PrivilegedAction() {
+                public Object run()  {
+                    daemonThread.setContextClassLoader(null);
+                    return null;
+                }
+            });
+        } catch (SecurityException se) {
+            // ignore security exception.  Earlier versions of Derby, before the 
+            // DERBY-3745 fix did not require setContextClassloader permissions.
+            // We may leak class loaders if we are not able to set this, but 
+            // cannot just fail.
+        }
 
 
 		daemonThread.start();

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java?rev=691364&r1=691363&r2=691364&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
Tue Sep  2 13:16:53 2008
@@ -54,7 +54,7 @@
 import org.apache.derby.iapi.services.loader.InstanceGetter;
 import org.apache.derby.iapi.services.io.FormatableInstanceGetter;
 import org.apache.derby.iapi.error.ExceptionSeverity;
-import org.apache.derby.iapi.util.PrivilegedThreadOps;
+
 
 import  org.apache.derby.io.StorageFactory;
 
@@ -94,6 +94,7 @@
 import java.lang.reflect.InvocationTargetException;
 
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.security.PrivilegedActionException;
 
@@ -273,11 +274,24 @@
 		keepItems[2] = msgService;
 		dontGC = new AntiGC(keepItems);
 
-		Thread dontGCthread = getDaemonThread(dontGC, "antiGC", true);
+		final Thread dontGCthread = getDaemonThread(dontGC, "antiGC", true);
 		// DERBY-3745.  setContextClassLoader for thread to null to avoid
 		// leaking class loaders.
-		PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
-						dontGCthread, null);
+		try {
+            AccessController.doPrivileged(
+            new PrivilegedAction() {
+                public Object run()  {
+                    
+                    dontGCthread.setContextClassLoader(null);
+                    return null;
+                }
+            });
+        } catch (SecurityException se1) {
+            // ignore security exception.  Earlier versions of Derby, before the 
+            // DERBY-3745 fix did not require setContextClassloader permissions.
+            // We may leak class loaders if we are not able to set this, but 
+            // cannot just fail.
+        }
 
 		dontGCthread.start();
 

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java?rev=691364&r1=691363&r2=691364&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
Tue Sep  2 13:16:53 2008
@@ -23,9 +23,10 @@
 
 import org.apache.derby.iapi.services.timer.TimerFactory;
 import org.apache.derby.iapi.services.monitor.ModuleControl;
-import org.apache.derby.iapi.util.PrivilegedThreadOps;
 import org.apache.derby.iapi.error.StandardException;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Timer;
 import java.util.Properties;
 
@@ -67,8 +68,12 @@
         ClassLoader savecl = null;
         boolean hasGetClassLoaderPerms = false;
         try {
-            savecl = PrivilegedThreadOps.getContextClassLoader(
-                    Thread.currentThread());
+            savecl = (ClassLoader)AccessController.doPrivileged(
+            new PrivilegedAction() {
+                public Object run()  {
+                    return Thread.currentThread().getContextClassLoader();
+                }
+            });
             hasGetClassLoaderPerms = true;
         } catch (SecurityException se) {
             // Ignore security exception. Versions of Derby before
@@ -77,12 +82,37 @@
             // able to do this but we can't just fail.
         }
         if (hasGetClassLoaderPerms)
-            PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
-                    Thread.currentThread(), null);
+            try {
+                AccessController.doPrivileged(
+                new PrivilegedAction() {
+                    public Object run()  {
+                        Thread.currentThread().setContextClassLoader(null);
+                        return null;
+                    }
+                });
+            } catch (SecurityException se) {
+                // ignore security exception.  Earlier versions of Derby, before the 
+                // DERBY-3745 fix did not require setContextClassloader permissions.
+                // We may leak class loaders if we are not able to set this, but 
+                // cannot just fail.
+            }
         singletonTimer = new Timer(true); // Run as daemon
         if (hasGetClassLoaderPerms)
-            PrivilegedThreadOps.setContextClassLoaderIfPrivileged(
-                    Thread.currentThread(), savecl);
+            try {
+                final ClassLoader tmpsavecl = savecl;
+                AccessController.doPrivileged(
+                new PrivilegedAction() {
+                    public Object run()  {
+                        Thread.currentThread().setContextClassLoader(tmpsavecl);
+                        return null;
+                    }
+                });
+            } catch (SecurityException se) {
+                // ignore security exception.  Earlier versions of Derby, before the 
+                // DERBY-3745 fix did not require setContextClassloader permissions.
+                // We may leak class loaders if we are not able to set this, but 
+                // cannot just fail.
+            }
     }
 
     /**



Mime
View raw message