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 ka...@apache.org on 2013/05/31 13:12:30 UTC
svn commit: r1488156 - in /db/derby/code/branches/10.10: ./
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/u...
Author: kahatlen
Date: Fri May 31 11:12:29 2013
New Revision: 1488156
URL: http://svn.apache.org/r1488156
Log:
DERBY-6224: Many test failures on latest JDK 8 EA build because of missing SQLPermission
Merged revision 1488125 from trunk.
Modified:
db/derby/code/branches/10.10/ (props changed)
db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
db/derby/code/branches/10.10/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy
db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
Merged /db/derby/code/trunk:r1488125
Modified: db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=1488156&r1=1488155&r2=1488156&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original)
+++ db/derby/code/branches/10.10/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Fri May 31 11:12:29 2013
@@ -904,7 +904,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.10/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java?rev=1488156&r1=1488155&r2=1488156&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java Fri May 31 11:12:29 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<Void>() {
+ public Void 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.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy?rev=1488156&r1=1488155&r2=1488156&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy Fri May 31 11:12:29 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.10/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?rev=1488156&r1=1488155&r2=1488156&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy (original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy Fri May 31 11:12:29 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