harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r553376 - in /harmony/enhanced/classlib/trunk/modules/sql: META-INF/ src/main/java/java/sql/ src/test/java/org/apache/harmony/sql/tests/java/sql/
Date Thu, 05 Jul 2007 05:53:45 GMT
Author: leoli
Date: Wed Jul  4 22:53:44 2007
New Revision: 553376

URL: http://svn.apache.org/viewvc?view=rev&rev=553376
Log:
Apply patch for HARMONY-4303([classlib][sql] java.sql.DriverManager.getDrivers() will read
System prpperty "jdbc.drivers" cause java.lang.ExceptionInInitializerError
).

Added:
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestMainForDriver.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF
    harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
    harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF?view=diff&rev=553376&r1=553375&r2=553376
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/META-INF/MANIFEST.MF Wed Jul  4 22:53:44 2007
@@ -27,7 +27,8 @@
  javax.naming,
  org.apache.harmony.kernel.vm,
  org.apache.harmony.luni.util,
- org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=optional
+ org.apache.harmony.testframework.serialization;hy_usage=test;resolution:=optional,
+ tests.support;hy_usage=test;resolution:=optional
 Export-Package: java.sql,
  javax.sql,
  javax.sql.rowset,

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java?view=diff&rev=553376&r1=553375&r2=553376
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/DriverManager.java
Wed Jul  4 22:53:44 2007
@@ -22,11 +22,11 @@
 import java.util.Properties;
 import java.util.Enumeration;
 import java.util.Iterator;
-import java.util.Set;
 import java.io.PrintStream;
 import java.io.PrintWriter;
-import java.util.HashSet;
 import java.util.Vector;
+import java.security.AccessController;
+import org.apache.harmony.luni.util.PriviAction;
 import org.apache.harmony.sql.internal.nls.Messages;
 import org.apache.harmony.kernel.vm.VM;
 
@@ -70,7 +70,9 @@
      * it is defined.
      */
     private static void loadInitialDrivers() {
-        String theDriverList = System.getProperty("jdbc.drivers", null); //$NON-NLS-1$
+        String theDriverList = AccessController
+                .doPrivileged(new PriviAction<String>("jdbc.drivers", null)); //$NON-NLS-1$
+
         if (theDriverList == null) {
             return;
         }

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java?view=diff&rev=553376&r1=553375&r2=553376
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/DriverManagerTest.java
Wed Jul  4 22:53:44 2007
@@ -18,6 +18,7 @@
 package org.apache.harmony.sql.tests.java.sql;
 
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.lang.reflect.Method;
@@ -30,6 +31,7 @@
 import java.sql.SQLPermission;
 import java.util.Enumeration;
 import java.util.Properties;
+import tests.support.Support_Exec;
 
 import junit.framework.TestCase;
 
@@ -601,6 +603,16 @@
         }
         Driver d = DriverManager.getDriver("jdbc:dummy_protocol:dummy_subname");
         assertNotNull(d);
+    }
+    
+    /**
+     * Regression for HARMONY-4303
+     */
+    public void test_initClass() throws Exception {
+        String[] arg = new String[1];
+        arg[0] = "org/apache/harmony/sql/tests/java/sql/TestMainForDriver";
+        String result = Support_Exec.execJava(arg, null, true);
+        assertEquals("", result);
     }
     
     private static class BadDummyDriver extends DummyDriver {

Added: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestMainForDriver.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestMainForDriver.java?view=auto&rev=553376
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestMainForDriver.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestMainForDriver.java
Wed Jul  4 22:53:44 2007
@@ -0,0 +1,36 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.sql.tests.java.sql;
+
+/*
+ * Load DriverManager class and initialize the class with SecurityManager
+ * Regression for HARMONY-4303
+ */
+public class TestMainForDriver {
+    public static void main(String[] args) throws Throwable {
+        // Install SecurityManager
+        System.setSecurityManager(new SecurityManager());
+        // Load java.sql.DriverManager and it will invoke its <clinit> method
+        try{
+            Class.forName("java.sql.DriverManager");
+        }catch (ExceptionInInitializerError e){
+            // ExceptionInInitializerError is caused by AccessControlException
+            throw e.getException();
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TestMainForDriver.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message