You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2008/08/22 08:20:48 UTC
svn commit: r687967 - in
/db/derby/code/branches/10.4/java/engine/org/apache/derby: iapi/util/
impl/services/daemon/ impl/services/jmx/ impl/services/monitor/
impl/services/timer/
Author: mamta
Date: Thu Aug 21 23:20:47 2008
New Revision: 687967
URL: http://svn.apache.org/viewvc?rev=687967&view=rev
Log:
DERBY-3745 : Backporting revisions 679620, 685674 and 686296 from the trunk into 10.4 codeline
derbyall tests ran fine. I ran junit test suites with classes and with jar files after backporting these changes to my 10.4 client. With classes, I ran into DERBY-3836 but didn't run into DERBY-3836 with jar files. I did run into some out of memory issues but I think it might be local to my machine because of all the other processes running on the machine and probably not enough memory to the junit tests when I specified -Xmx1024m. I will keep an eye on the 10.4 test runs after I commit the changes.
Removed:
db/derby/code/branches/10.4/java/engine/org/apache/derby/iapi/util/PrivilegedThreadOps.java
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/jmx/JMXManagementService.java
db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java
db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.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=687967&r1=687966&r2=687967&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 Thu Aug 21 23:20:47 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.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java?rev=687967&r1=687966&r2=687967&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/jmx/JMXManagementService.java Thu Aug 21 23:20:47 2008
@@ -41,7 +41,6 @@
import org.apache.derby.iapi.services.monitor.ModuleControl;
import org.apache.derby.iapi.services.monitor.Monitor;
import org.apache.derby.iapi.services.property.PropertyUtil;
-import org.apache.derby.iapi.util.PrivilegedThreadOps;
import org.apache.derby.mbeans.ManagementMBean;
import org.apache.derby.mbeans.VersionMBean;
import org.apache.derby.security.SystemPermission;
@@ -170,10 +169,16 @@
// sure the context class loader is null before we start the MBean
// server which will create threads that we want to have a null context
// class loader
- ClassLoader savecl = null;
+
boolean hasGetClassLoaderPerms=false;
+ ClassLoader savecl = null;
try {
- savecl = PrivilegedThreadOps.getContextClassLoader(Thread.currentThread());
+ savecl = (ClassLoader)AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
hasGetClassLoaderPerms = true;
} catch (SecurityException se) {
// ignore security exception. Earlier versions of Derby, before the
@@ -182,8 +187,21 @@
// cannot just fail.
}
if (hasGetClassLoaderPerms)
- PrivilegedThreadOps.setContextClassLoaderIfPrivileged(Thread.
- currentThread(), null);
+ try {
+ AccessController.doPrivileged(
+ new PrivilegedAction<Object>() {
+ public Object run() {
+ Thread.
+ currentThread().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.
+ }
try {
mbeanServer = AccessController
.doPrivileged(new PrivilegedAction<MBeanServer>() {
@@ -201,8 +219,21 @@
// starts the MBean server.
}
if (hasGetClassLoaderPerms)
- PrivilegedThreadOps.setContextClassLoaderIfPrivileged(Thread.currentThread(),
- savecl);
+ try {
+ final ClassLoader tmpsavecl = savecl;
+ AccessController.doPrivileged(
+ new PrivilegedAction<Object>() {
+ 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.
+ }
}
/**
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=687967&r1=687966&r2=687967&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 Thu Aug 21 23:20:47 2008
@@ -56,7 +56,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;
@@ -96,6 +96,7 @@
import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.security.PrivilegedActionException;
@@ -275,11 +276,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.4/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java?rev=687967&r1=687966&r2=687967&view=diff
==============================================================================
--- db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java (original)
+++ db/derby/code/branches/10.4/java/engine/org/apache/derby/impl/services/timer/SingletonTimerFactory.java Thu Aug 21 23:20:47 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.
+ }
}
/**