db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1627831 [4/4] - in /db/derby/code/trunk/java: drda/org/apache/derby/drda/ drda/org/apache/derby/impl/drda/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/iapi/services/context/ engine/org/apache/derby/iapi/services/monitor/ eng...
Date Fri, 26 Sep 2014 17:12:33 GMT
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_RecoverBadLog.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_RecoverBadLog.java?rev=1627831&r1=1627830&r2=1627831&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_RecoverBadLog.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_RecoverBadLog.java
Fri Sep 26 17:12:31 2014
@@ -53,6 +53,8 @@ import java.io.RandomAccessFile;
 import java.io.File;
 import java.security.PrivilegedAction;
 import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Properties;
 
 
@@ -260,7 +262,7 @@ public class T_RecoverBadLog extends T_G
 				// remove the service directory to ensure a clean run
 				startParams.put(Property.DELETE_ON_CREATE, Boolean.TRUE.toString());
 
-				factory = (RawStoreFactory) Monitor.createPersistentService(getModuleToTestProtocolName(),
+				factory = (RawStoreFactory) createPersistentService(getModuleToTestProtocolName(),
 															  testService,
 															  startParams);
 				// create a database with nothing
@@ -316,11 +318,11 @@ public class T_RecoverBadLog extends T_G
 					throw T_Fail.exceptionFail(ioe);
 				}
 
-				if (!Monitor.startPersistentService(testService, startParams))
+				if (!startPersistentService(testService, startParams))
 					throw T_Fail.testFailMsg("Monitor didn't know how to restart service: " + testService);
 
 				factory = (RawStoreFactory) Monitor.findService(getModuleToTestProtocolName(), testService);
-				logFactory =(LogToFile) Monitor.findServiceModule(factory, factory.getLogFactoryModule());
+				logFactory =(LogToFile) findServiceModule(factory, factory.getLogFactoryModule());
 				
 			}
 		} catch (StandardException mse) {
@@ -1836,22 +1838,90 @@ public class T_RecoverBadLog extends T_G
      */
     private  static  ContextService    getContextService()
     {
-        if ( System.getSecurityManager() == null )
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<ContextService>()
+             {
+                 public ContextService run()
+                 {
+                     return ContextService.getFactory();
+                 }
+             }
+             );
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object findServiceModule( final Object serviceModule, final String factoryInterface)
+        throws StandardException
+    {
+        try {
+            return AccessController.doPrivileged
+                (
+                 new PrivilegedExceptionAction<Object>()
+                 {
+                     public Object run()
+                         throws StandardException
+                     {
+                         return Monitor.findServiceModule( serviceModule, factoryInterface
);
+                     }
+                 }
+                 );
+        } catch (PrivilegedActionException pae)
         {
-            return ContextService.getFactory();
+            throw StandardException.plainWrapException( pae );
         }
-        else
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  boolean startPersistentService( final String serviceName, final Properties
properties ) 
+        throws StandardException
+    {
+        try {
+            return AccessController.doPrivileged
+                (
+                 new PrivilegedExceptionAction<Boolean>()
+                 {
+                     public Boolean run()
+                         throws StandardException
+                     {
+                         return Monitor.startPersistentService( serviceName, properties );
+                     }
+                 }
+                 );
+        } catch (PrivilegedActionException pae)
         {
+            throw StandardException.plainWrapException( pae );
+        }
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object createPersistentService( final String factoryInterface, final
String serviceName, final Properties properties ) 
+        throws StandardException
+    {
+        try {
             return AccessController.doPrivileged
                 (
-                 new PrivilegedAction<ContextService>()
+                 new PrivilegedExceptionAction<Object>()
                  {
-                     public ContextService run()
+                     public Object run()
+                         throws StandardException
                      {
-                         return ContextService.getFactory();
+                         return Monitor.createPersistentService( factoryInterface, serviceName,
properties );
                      }
                  }
                  );
+        } catch (PrivilegedActionException pae)
+        {
+            throw StandardException.plainWrapException( pae );
         }
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_RecoverFullLog.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_RecoverFullLog.java?rev=1627831&r1=1627830&r2=1627831&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_RecoverFullLog.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_RecoverFullLog.java
Fri Sep 26 17:12:31 2014
@@ -52,6 +52,8 @@ import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.io.File;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.security.AccessController;
 import java.util.Properties;
 
@@ -193,7 +195,7 @@ public class T_RecoverFullLog extends T_
 				// remove the service directory to ensure a clean run
 				startParams.put(Property.DELETE_ON_CREATE, Boolean.TRUE.toString());
 
-				factory = (RawStoreFactory) Monitor.createPersistentService(getModuleToTestProtocolName(),
+				factory = (RawStoreFactory) createPersistentService(getModuleToTestProtocolName(),
 																  testService,
 																  startParams);
 				// create a database with nothing
@@ -247,9 +249,9 @@ public class T_RecoverFullLog extends T_
 					System.setProperty(LogToFile.TEST_RECORD_TO_FILL_LOG, "10");
 				}
 
-				if (!Monitor.startPersistentService(testService, startParams))
+				if (!startPersistentService(testService, startParams))
 					throw T_Fail.testFailMsg("Monitor didn't know how to restart service: " + testService);
-				factory = (RawStoreFactory) Monitor.findService(getModuleToTestProtocolName(), testService);
+				factory = (RawStoreFactory) findService(getModuleToTestProtocolName(), testService);
 
 				if (recoveryFail)
 				{
@@ -871,26 +873,87 @@ public class T_RecoverFullLog extends T_
      */
     private  static  ContextService    getContextService()
     {
-        if ( System.getSecurityManager() == null )
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<ContextService>()
+             {
+                 public ContextService run()
+                 {
+                     return ContextService.getFactory();
+                 }
+             }
+             );
+    }
+
+
+    /**
+     * Privileged service lookup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private static  Object findService( final String factoryInterface, final String serviceName
)
+    {
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<Object>()
+             {
+                 public Object run()
+                 {
+                     return Monitor.findService( factoryInterface, serviceName );
+                 }
+             }
+             );
+    }
+    
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  boolean startPersistentService( final String serviceName, final Properties
properties ) 
+        throws StandardException
+    {
+        try {
+            return AccessController.doPrivileged
+                (
+                 new PrivilegedExceptionAction<Boolean>()
+                 {
+                     public Boolean run()
+                         throws StandardException
+                     {
+                         return Monitor.startPersistentService( serviceName, properties );
+                     }
+                 }
+                 ).booleanValue();
+        } catch (PrivilegedActionException pae)
         {
-            return ContextService.getFactory();
+            throw StandardException.plainWrapException( pae );
         }
-        else
-        {
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object createPersistentService( final String factoryInterface, final
String serviceName, final Properties properties ) 
+        throws StandardException
+    {
+        try {
             return AccessController.doPrivileged
                 (
-                 new PrivilegedAction<ContextService>()
+                 new PrivilegedExceptionAction<Object>()
                  {
-                     public ContextService run()
+                     public Object run()
+                         throws StandardException
                      {
-                         return ContextService.getFactory();
+                         return Monitor.createPersistentService( factoryInterface, serviceName,
properties );
                      }
                  }
                  );
+        } catch (PrivilegedActionException pae)
+        {
+            throw StandardException.plainWrapException( pae );
         }
     }
 
-
 }
 
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Recovery.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Recovery.java?rev=1627831&r1=1627830&r2=1627831&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Recovery.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_Recovery.java
Fri Sep 26 17:12:31 2014
@@ -34,6 +34,7 @@ import org.apache.derby.iapi.services.co
 import org.apache.derby.iapi.services.context.ContextManager;
 import org.apache.derby.iapi.services.locks.*;
 import org.apache.derby.iapi.services.property.PropertyUtil;
+import org.apache.derby.iapi.services.monitor.ModuleFactory;
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.shared.common.sanity.SanityManager;
 
@@ -60,6 +61,8 @@ import org.apache.derby.iapi.services.io
 
 import java.io.*;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.security.AccessController;
 import java.util.Properties;
 
@@ -168,7 +171,7 @@ public class T_Recovery extends T_Generi
 
 		try {
 
-			uuidfactory = Monitor.getMonitor().getUUIDFactory();
+			uuidfactory = getMonitor().getUUIDFactory();
 			if (uuidfactory == null) {
 				throw T_Fail.testFailMsg("UUIDFactory.MODULE not found");
 			}
@@ -180,9 +183,9 @@ public class T_Recovery extends T_Generi
 
 			if (testRecovery)
 			{
-				if (!Monitor.startPersistentService(testService, startParams))
+				if (!startPersistentService(testService, startParams))
 					throw T_Fail.testFailMsg("Monitor didn't know how to restart service: " + testService);
-				factory = (RawStoreFactory) Monitor.findService(getModuleToTestProtocolName(), testService);
+				factory = (RawStoreFactory) findService(getModuleToTestProtocolName(), testService);
 
 			}
 			else					// setup
@@ -202,7 +205,7 @@ public class T_Recovery extends T_Generi
 				// keep all log files for diagnostics
 				startParams.put(RawStoreFactory.KEEP_TRANSACTION_LOG, "true");
 
-				factory = (RawStoreFactory) Monitor.createPersistentService(getModuleToTestProtocolName(),
+				factory = (RawStoreFactory) createPersistentService(getModuleToTestProtocolName(),
 																  testService,
 																  startParams);
 			}
@@ -4094,22 +4097,102 @@ public class T_Recovery extends T_Generi
      */
     private  static  ContextService    getContextService()
     {
-        if ( System.getSecurityManager() == null )
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<ContextService>()
+             {
+                 public ContextService run()
+                 {
+                     return ContextService.getFactory();
+                 }
+             }
+             );
+    }
+
+    
+    /**
+     * Privileged Monitor lookup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  ModuleFactory  getMonitor()
+    {
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<ModuleFactory>()
+             {
+                 public ModuleFactory run()
+                 {
+                     return Monitor.getMonitor();
+                 }
+             }
+             );
+    }
+
+    /**
+     * Privileged service lookup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private static  Object findService( final String factoryInterface, final String serviceName
)
+    {
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<Object>()
+             {
+                 public Object run()
+                 {
+                     return Monitor.findService( factoryInterface, serviceName );
+                 }
+             }
+             );
+    }
+    
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  boolean startPersistentService( final String serviceName, final Properties
properties ) 
+        throws StandardException
+    {
+        try {
+            return AccessController.doPrivileged
+                (
+                 new PrivilegedExceptionAction<Boolean>()
+                 {
+                     public Boolean run()
+                         throws StandardException
+                     {
+                         return Monitor.startPersistentService( serviceName, properties );
+                     }
+                 }
+                 ).booleanValue();
+        } catch (PrivilegedActionException pae)
         {
-            return ContextService.getFactory();
+            throw StandardException.plainWrapException( pae );
         }
-        else
-        {
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object createPersistentService( final String factoryInterface, final
String serviceName, final Properties properties ) 
+        throws StandardException
+    {
+        try {
             return AccessController.doPrivileged
                 (
-                 new PrivilegedAction<ContextService>()
+                 new PrivilegedExceptionAction<Object>()
                  {
-                     public ContextService run()
+                     public Object run()
+                         throws StandardException
                      {
-                         return ContextService.getFactory();
+                         return Monitor.createPersistentService( factoryInterface, serviceName,
properties );
                      }
                  }
                  );
+        } catch (PrivilegedActionException pae)
+        {
+            throw StandardException.plainWrapException( pae );
         }
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java?rev=1627831&r1=1627830&r2=1627831&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_SortController.java
Fri Sep 26 17:12:31 2014
@@ -46,6 +46,8 @@ import org.apache.derby.iapi.types.SQLIn
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Properties;
 import java.util.Vector;
 import java.util.StringTokenizer;
@@ -134,7 +136,7 @@ public class T_SortController extends T_
 		int failcount = 0;
 
 		try {
-			store = (AccessFactory) Monitor.createPersistentService(getModuleToTestProtocolName(),

+			store = (AccessFactory) createPersistentService(getModuleToTestProtocolName(), 
 				testService + tail, startParams);
 		} catch (StandardException mse) {
 			throw T_Fail.exceptionFail(mse);
@@ -864,6 +866,31 @@ public class T_SortController extends T_
         }
     }
 
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object createPersistentService( final String factoryInterface, final
String serviceName, final Properties properties ) 
+        throws StandardException
+    {
+        try {
+            return AccessController.doPrivileged
+                (
+                 new PrivilegedExceptionAction<Object>()
+                 {
+                     public Object run()
+                         throws StandardException
+                     {
+                         return Monitor.createPersistentService( factoryInterface, serviceName,
properties );
+                     }
+                 }
+                 );
+        } catch (PrivilegedActionException pae)
+        {
+            throw StandardException.plainWrapException( pae );
+        }
+    }
+
 }
 
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_StreamFile.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_StreamFile.java?rev=1627831&r1=1627830&r2=1627831&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_StreamFile.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_StreamFile.java
Fri Sep 26 17:12:31 2014
@@ -51,6 +51,8 @@ import org.apache.derby.iapi.services.io
 
 import java.io.*;
 import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.security.AccessController;
 import java.util.Properties;
 
@@ -129,7 +131,7 @@ public class T_StreamFile extends T_Mult
 		startParams = T_Util.setEncryptionParam(startParams);
 
 		try {
-			factory = (RawStoreFactory) Monitor.createPersistentService(getModuleToTestProtocolName(),
+			factory = (RawStoreFactory) createPersistentService(getModuleToTestProtocolName(),
 								testService, startParams);
 			if (factory == null) {
 				throw T_Fail.testFailMsg(getModuleToTestProtocolName() + " service not started.");
@@ -398,22 +400,40 @@ public class T_StreamFile extends T_Mult
      */
     private  static  ContextService    getContextService()
     {
-        if ( System.getSecurityManager() == null )
-        {
-            return ContextService.getFactory();
-        }
-        else
-        {
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<ContextService>()
+             {
+                 public ContextService run()
+                 {
+                     return ContextService.getFactory();
+                 }
+             }
+             );
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object createPersistentService( final String factoryInterface, final
String serviceName, final Properties properties ) 
+        throws StandardException
+    {
+        try {
             return AccessController.doPrivileged
                 (
-                 new PrivilegedAction<ContextService>()
+                 new PrivilegedExceptionAction<Object>()
                  {
-                     public ContextService run()
+                     public Object run()
+                         throws StandardException
                      {
-                         return ContextService.getFactory();
+                         return Monitor.createPersistentService( factoryInterface, serviceName,
properties );
                      }
                  }
                  );
+        } catch (PrivilegedActionException pae)
+        {
+            throw StandardException.plainWrapException( pae );
         }
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_XA.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_XA.java?rev=1627831&r1=1627830&r2=1627831&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_XA.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_XA.java Fri
Sep 26 17:12:31 2014
@@ -42,6 +42,8 @@ import org.apache.derby.iapi.services.io
 
 import org.apache.derby.iapi.error.StandardException; 
 
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.security.PrivilegedAction;
 import java.security.AccessController;
 import java.util.Properties; 
@@ -113,7 +115,7 @@ public class T_XA extends T_Generic
 		startParams = T_Util.setEncryptionParam(startParams);
 
 		try {
-			store = (AccessFactory) Monitor.createPersistentService(
+			store = (AccessFactory) createPersistentService(
 				getModuleToTestProtocolName(), testService, startParams);
 		} catch (StandardException mse) {
 			throw T_Fail.exceptionFail(mse);
@@ -1189,25 +1191,42 @@ public class T_XA extends T_Generic
      */
     static  ContextService    getContextService()
     {
-        if ( System.getSecurityManager() == null )
-        {
-            return ContextService.getFactory();
-        }
-        else
-        {
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<ContextService>()
+             {
+                 public ContextService run()
+                 {
+                     return ContextService.getFactory();
+                 }
+             }
+             );
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object createPersistentService( final String factoryInterface, final
String serviceName, final Properties properties ) 
+        throws StandardException
+    {
+        try {
             return AccessController.doPrivileged
                 (
-                 new PrivilegedAction<ContextService>()
+                 new PrivilegedExceptionAction<Object>()
                  {
-                     public ContextService run()
+                     public Object run()
+                         throws StandardException
                      {
-                         return ContextService.getFactory();
+                         return Monitor.createPersistentService( factoryInterface, serviceName,
properties );
                      }
                  }
                  );
+        } catch (PrivilegedActionException pae)
+        {
+            throw StandardException.plainWrapException( pae );
         }
     }
-
 }
 
 class commit_method
@@ -1313,4 +1332,5 @@ class commit_method
                 cm, xid);
         }
     }
+
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_b2i.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_b2i.java?rev=1627831&r1=1627830&r2=1627831&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_b2i.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/store/T_b2i.java Fri
Sep 26 17:12:31 2014
@@ -71,6 +71,8 @@ import org.apache.derby.iapi.types.SQLCh
 
 import java.security.PrivilegedAction;
 import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Properties;
 
 
@@ -111,7 +113,7 @@ public class T_b2i extends T_MultiIterat
 
 
 		try {
-			store_module = Monitor.createPersistentService(
+			store_module = createPersistentService(
 				getModuleToTestProtocolName(), testService, startParams);
 			
 			contextService = getContextService();
@@ -1624,7 +1626,7 @@ public class T_b2i extends T_MultiIterat
 
         // flush and empty cache to make sure rereading stuff works.
         RawStoreFactory rawstore = 
-            (RawStoreFactory) Monitor.findServiceModule(
+            (RawStoreFactory) findServiceModule(
                 this.store_module, RawStoreFactory.MODULE);
 
         rawstore.idle();
@@ -5137,22 +5139,65 @@ public class T_b2i extends T_MultiIterat
      */
     private  static  Context    getContextOrNull( final String contextID )
     {
-        if ( System.getSecurityManager() == null )
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<Context>()
+             {
+                 public Context run()
+                 {
+                     return ContextService.getContextOrNull( contextID );
+                 }
+             }
+             );
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object findServiceModule( final Object serviceModule, final String factoryInterface)
+        throws StandardException
+    {
+        try {
+            return AccessController.doPrivileged
+                (
+                 new PrivilegedExceptionAction<Object>()
+                 {
+                     public Object run()
+                         throws StandardException
+                     {
+                         return Monitor.findServiceModule( serviceModule, factoryInterface
);
+                     }
+                 }
+                 );
+        } catch (PrivilegedActionException pae)
         {
-            return ContextService.getContextOrNull( contextID );
+            throw StandardException.plainWrapException( pae );
         }
-        else
-        {
+    }
+
+    /**
+     * Privileged startup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  Object createPersistentService( final String factoryInterface, final
String serviceName, final Properties properties ) 
+        throws StandardException
+    {
+        try {
             return AccessController.doPrivileged
                 (
-                 new PrivilegedAction<Context>()
+                 new PrivilegedExceptionAction<Object>()
                  {
-                     public Context run()
+                     public Object run()
+                         throws StandardException
                      {
-                         return ContextService.getContextOrNull( contextID );
+                         return Monitor.createPersistentService( factoryInterface, serviceName,
properties );
                      }
                  }
                  );
+        } catch (PrivilegedActionException pae)
+        {
+            throw StandardException.plainWrapException( pae );
         }
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/util/MsgTrace.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/util/MsgTrace.java?rev=1627831&r1=1627830&r2=1627831&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/util/MsgTrace.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/util/MsgTrace.java
Fri Sep 26 17:12:31 2014
@@ -21,6 +21,10 @@
 
 package org.apache.derbyTesting.unitTests.util;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.derby.iapi.services.monitor.ModuleFactory;
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.shared.common.sanity.SanityManager;
 import org.apache.derby.iapi.services.stream.HeaderPrintWriter;
@@ -52,7 +56,7 @@ public class MsgTrace implements Runnabl
 
 	private MsgTrace() {
 
-		output = Monitor.getMonitor().getSystemStreams().stream();
+		output = getMonitor().getSystemStreams().stream();
 
 		bombDelay = PropertyUtil.getSystemInt(DELAY_PARAM_NAME, 30 * 60); // 30 minutes default
 		bombDelay *= 1000;
@@ -87,4 +91,23 @@ public class MsgTrace implements Runnabl
 
 		System.exit(1);
 	}
+    
+    /**
+     * Privileged Monitor lookup. Must be private so that user code
+     * can't call this entry point.
+     */
+    private  static  ModuleFactory  getMonitor()
+    {
+        return AccessController.doPrivileged
+            (
+             new PrivilegedAction<ModuleFactory>()
+             {
+                 public ModuleFactory run()
+                 {
+                     return Monitor.getMonitor();
+                 }
+             }
+             );
+    }
+
 }



Mime
View raw message