db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1494758 - in /db/derby/code/branches/10.10: ./ java/engine/org/apache/derby/jdbc/ java/engine/org/apache/derby/loc/ java/shared/org/apache/derby/shared/common/reference/ java/testing/org/apache/derbyTesting/functionTests/tests/engine/
Date Wed, 19 Jun 2013 20:05:54 GMT
Author: kahatlen
Date: Wed Jun 19 20:05:53 2013
New Revision: 1494758

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

Merged revision 1493077 from trunk.

Added:
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java
      - copied, changed from r1493077, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/noDeregisterPermission.policy
      - copied unchanged from r1493077, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/noDeregisterPermission.policy
Modified:
    db/derby/code/branches/10.10/   (props changed)
    db/derby/code/branches/10.10/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
    db/derby/code/branches/10.10/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/branches/10.10/java/shared/org/apache/derby/shared/common/reference/MessageId.java
    db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java

Propchange: db/derby/code/branches/10.10/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1493077

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=1494758&r1=1494757&r2=1494758&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 Wed
Jun 19 20:05:53 2013
@@ -27,18 +27,17 @@ import java.sql.Connection;
 import java.sql.DriverPropertyInfo;
 import java.sql.SQLException;
 
-import java.io.PrintStream;
+import java.security.AccessControlException;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.Properties;
 
 import org.apache.derby.iapi.reference.MessageId;
-import org.apache.derby.iapi.reference.Attribute;
 import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.jdbc.JDBCBoot;
+import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.impl.jdbc.Util;
 
 
@@ -281,6 +280,14 @@ public class AutoloadedDriver implements
             });
         } catch (PrivilegedActionException pae) {
             throw (SQLException) pae.getCause();
+        } catch (AccessControlException ace) {
+            // Since no permission was needed for deregisterDriver() before
+            // Java 8, applications may be surprised to find that engine
+            // shutdown fails because of it. For backward compatibility,
+            // don't fail shutdown if the permission is missing. Instead,
+            // log a message saying the driver could not be deregistered.
+            Monitor.logTextMessage(MessageId.CONN_DEREGISTER_NOT_PERMITTED);
+            Monitor.logThrowable(ace);
         }
     }
 

Modified: db/derby/code/branches/10.10/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/engine/org/apache/derby/loc/messages.xml?rev=1494758&r1=1494757&r2=1494758&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/branches/10.10/java/engine/org/apache/derby/loc/messages.xml Wed Jun 19
20:05:53 2013
@@ -8217,6 +8217,11 @@ Shutting down instance {0} on database d
                 <text>There was an XA transaction associated with the connection being
closed. The transaction is going to be rolled back. The transaction Xid is {0}.</text>
                 <arg>transactionXid</arg>
             </msg>
+
+            <msg>
+                <name>J137</name>
+                <text>Could not deregister the JDBC driver when shutting down the Derby
engine. Make sure SQLPermission("deregisterDriver") is granted to derby.jar.</text>
+            </msg>
         </family>
 
 

Modified: db/derby/code/branches/10.10/java/shared/org/apache/derby/shared/common/reference/MessageId.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/shared/org/apache/derby/shared/common/reference/MessageId.java?rev=1494758&r1=1494757&r2=1494758&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/shared/org/apache/derby/shared/common/reference/MessageId.java
(original)
+++ db/derby/code/branches/10.10/java/shared/org/apache/derby/shared/common/reference/MessageId.java
Wed Jun 19 20:05:53 2013
@@ -174,6 +174,9 @@ public interface MessageId {
     String CONN_XA_TRANSACTION_TIMED_OUT                    = "J135";
     String CONN_CLOSE_XA_TRANSACTION_ROLLED_BACK            = "J136";
 
+    /** Shutdown couldn't deregister driver because of missing permission. */
+    String CONN_DEREGISTER_NOT_PERMITTED = "J137";
+
 	/*
 	** Authentication
 	*/

Copied: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java
(from r1493077, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java)
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java?p2=db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java&p1=db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java&r1=1493077&r2=1494758&rev=1494758&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/ShutdownWithoutDeregisterPermissionTest.java
Wed Jun 19 20:05:53 2013
@@ -64,10 +64,10 @@ public class ShutdownWithoutDeregisterPe
         // On Java 8/JDBC 4.2 and higher, we expect AutoloadedDriver to
         // be in the list of registered drivers.
 
-        Enumeration<Driver> drivers = DriverManager.getDrivers();
+        Enumeration drivers = DriverManager.getDrivers();
         Driver found = null;
         while (found == null && drivers.hasMoreElements()) {
-            Driver driver = drivers.nextElement();
+            Driver driver = (Driver) drivers.nextElement();
             if (driver.getClass().getName().startsWith(
                     "org.apache.derby.jdbc.AutoloadedDriver")) {
                 found = driver;

Modified: db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java?rev=1494758&r1=1494757&r2=1494758&view=diff
==============================================================================
--- db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
(original)
+++ db/derby/code/branches/10.10/java/testing/org/apache/derbyTesting/functionTests/tests/engine/_Suite.java
Wed Jun 19 20:05:53 2013
@@ -24,6 +24,7 @@ package org.apache.derbyTesting.function
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.apache.derbyTesting.junit.BaseTestCase;
+import org.apache.derbyTesting.junit.JDBC;
 
 /**
  * Suite to run all JUnit tests in this package:
@@ -53,6 +54,10 @@ public class _Suite extends BaseTestCase
             suite.addTest(RestrictiveFilePermissionsTest.suite());
         suite.addTest(ModuleLoadingTest.suite());
         suite.addTest(ReadMeFilesTest.suite());
+        if (JDBC.vmSupportsJDBC3()) {
+            // Test that requires DriverManager.
+            suite.addTest(ShutdownWithoutDeregisterPermissionTest.suite());
+        }
 
         return suite;
     }



Mime
View raw message