db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1490291 - in /db/derby/code/branches/10.9: ./ java/drda/org/apache/derby/impl/drda/ java/engine/org/apache/derby/jdbc/ java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ java/testing/org/apache/derbyTesting/functionTests/util/
Date Thu, 06 Jun 2013 14:04:00 GMT
Author: kahatlen
Date: Thu Jun  6 14:04:00 2013
New Revision: 1490291

URL: http://svn.apache.org/r1490291
Log:
DERBY-6224: Many test failures on latest JDK 8 EA build because of missing SQLPermission

Merged fix from trunk (revision 1488125).

Modified:
    db/derby/code/branches/10.9/   (props changed)
    db/derby/code/branches/10.9/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/branches/10.9/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
    db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy
    db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy

Propchange: db/derby/code/branches/10.9/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1488125

Modified: db/derby/code/branches/10.9/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=1490291&r1=1490290&r2=1490291&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/branches/10.9/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Thu Jun  6 14:04:00 2013
@@ -910,7 +910,14 @@ public final class NetworkServerControlI
 						if (passwordArg != null) {
 							p.setProperty("password", passwordArg);
 						}
-						cloudscapeDriver.connect("jdbc:derby:;shutdown=true", p);
+                        // DERBY-6224: DriverManager.deregisterDriver() requires
+                        // an extra permission in JDBC 4.2 and later. Invoke
+                        // system shutdown with deregister=false to avoid the
+                        // need for the extre permission in the default server
+                        // policy. Since the JVM is about to terminate, we don't
+                        // care whether the JDBC driver is deregistered.
+                        cloudscapeDriver.connect(
+                            "jdbc:derby:;shutdown=true;deregister=false", p);
 					}
 				} catch (SQLException sqle) {
 					// If we can't shutdown Derby, perhaps, authentication has

Modified: db/derby/code/branches/10.9/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java?rev=1490291&r1=1490290&r2=1490291&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java (original)
+++ db/derby/code/branches/10.9/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java Thu
Jun  6 14:04:00 2013
@@ -28,6 +28,9 @@ import java.sql.DriverPropertyInfo;
 import java.sql.SQLException;
 
 import java.io.PrintStream;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Properties;
 
 import org.apache.derby.iapi.reference.MessageId;
@@ -64,7 +67,7 @@ public class AutoloadedDriver implements
 	
 
     // This is the driver that memorizes the autoloadeddriver (DERBY-2905)
-    private static Driver _autoloadedDriver;
+    private static AutoloadedDriver _autoloadedDriver;
 
 	//
 	// This is the driver that's specific to the JDBC level we're running at.
@@ -247,20 +250,39 @@ public class AutoloadedDriver implements
         try {
             // deregister is false if user set deregister=false attribute (DERBY-2905)
             if (InternalDriver.getDeregister() && _autoloadedDriver != null) {
-                DriverManager.deregisterDriver(_autoloadedDriver);
+                deregisterDriver(_autoloadedDriver);
                 _autoloadedDriver = null;
-            } else {
-                DriverManager.deregisterDriver(_driverModule);
-                //DERBY 5085, need to restore the default value
-                InternalDriver.setDeregister(true);
             }
+
+            // DERBY-5085, need to restore the default value
+            InternalDriver.setDeregister(true);
+
             _driverModule = null;
         } catch (SQLException e) {
             if (SanityManager.DEBUG)
                 SanityManager.THROWASSERT(e);
         }
 	}
-	
+
+    private static void deregisterDriver(final AutoloadedDriver driver)
+            throws SQLException {
+        // DERBY-6224: DriverManager.deregisterDriver() requires a special
+        // permission in JDBC 4.2 and later. Call it in a privileged block
+        // so that the permission doesn't have to be granted to code that
+        // invokes engine shutdown.
+        try {
+            AccessController.doPrivileged(
+                    new PrivilegedExceptionAction() {
+                public Object run() throws SQLException {
+                    // Requires SQLPermission("deregisterDriver")
+                    DriverManager.deregisterDriver(driver);
+                    return null;
+                }
+            });
+        } catch (PrivilegedActionException pae) {
+            throw (SQLException) pae.getCause();
+        }
+    }
 
 	/*
 	** Return true if the engine has been booted.

Modified: db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy?rev=1490291&r1=1490290&r2=1490291&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy
(original)
+++ db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy
Thu Jun  6 14:04:00 2013
@@ -91,6 +91,10 @@ grant codeBase "${derbyTesting.codejar}d
   // Needed by FileUtil#limitAccessToOwner
   permission java.lang.RuntimePermission "accessUserInformation";
   permission java.lang.RuntimePermission "getFileStoreAttributes";
+
+  // This permission is needed to call DriverManager.deregisterDriver()
+  // on Java SE 8 and later.
+  permission java.sql.SQLPermission "deregisterDriver";
 };
 
 //
@@ -240,6 +244,10 @@ grant codeBase "${derbyTesting.codeclass
   // Needed by FileUtil#limitAccessToOwner
   permission java.lang.RuntimePermission "accessUserInformation";
   permission java.lang.RuntimePermission "getFileStoreAttributes";
+
+  // This permission is needed to call DriverManager.deregisterDriver()
+  // on Java SE 8 and later.
+  permission java.sql.SQLPermission "deregisterDriver";
 };
 
 // JUnit jar file tries to read junit.properties in the user's

Modified: db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?rev=1490291&r1=1490290&r2=1490291&view=diff
==============================================================================
--- db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
(original)
+++ db/derby/code/branches/10.9/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
Thu Jun  6 14:04:00 2013
@@ -136,6 +136,10 @@ grant codeBase "${derbyTesting.codejar}d
 
   // This permission is needed to call the Connection.abort(Executor) method added by JDBC
4.1
   permission java.sql.SQLPermission "callAbort";
+
+  // This permission is needed to call DriverManager.deregisterDriver()
+  // on Java SE 8 and later.
+  permission java.sql.SQLPermission "deregisterDriver";
 };
 
 //
@@ -364,6 +368,9 @@ grant codeBase "${derbyTesting.codeclass
   permission java.lang.RuntimePermission "accessUserInformation";
   permission java.lang.RuntimePermission "getFileStoreAttributes";
 
+  // This permission is needed to call DriverManager.deregisterDriver()
+  // on Java SE 8 and later.
+  permission java.sql.SQLPermission "deregisterDriver";
 };
 
 // JUnit jar file tries to read junit.properties in the user's



Mime
View raw message