db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r382497 - in /db/derby/code/branches/10.1/java: engine/org/apache/derby/impl/services/reflect/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/suites/ testing/org/apache/derbyTesting/funct...
Date Thu, 02 Mar 2006 20:07:20 GMT
Author: djd
Date: Thu Mar  2 12:07:19 2006
New Revision: 382497

URL: http://svn.apache.org/viewcvs?rev=382497&view=rev
Log:
DERBY-997 Fix ClassCastExceptions for queries containing aggregates when executi
ng in application servers
or other class loading environments where the thread context loader provides ano
ther path to the derby engine code.
Merge of 382450 from trunk.


Added:
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/AggregateClassLoading.out
  (props changed)
      - copied unchanged from r382450, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/AggregateClassLoading.out
Modified:
    db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/services/reflect/DatabaseClasses.java
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AggregateClassLoading.java

Modified: db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/services/reflect/DatabaseClasses.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/services/reflect/DatabaseClasses.java?rev=382497&r1=382496&r2=382497&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/services/reflect/DatabaseClasses.java
(original)
+++ db/derby/code/branches/10.1/java/engine/org/apache/derby/impl/services/reflect/DatabaseClasses.java
Thu Mar  2 12:07:19 2006
@@ -207,7 +207,24 @@
 
 	public final Class loadApplicationClass(String className)
 		throws ClassNotFoundException {
-
+        
+        if (className.startsWith("org.apache.derby.")) {
+            // Assume this is an engine class, if so
+            // try to load from this class loader,
+            // this ensures in strange class loader
+            // environments we do not get ClassCastExceptions
+            // when an engine class is loaded through a different
+            // class loader to the rest of the engine.
+            try {
+                return Class.forName(className);
+            } catch (ClassNotFoundException cnfe)
+            {
+                // fall through to the code below,
+                // could be client or tools class
+                // in a different loader.
+            }
+        }
+ 
 		Throwable loadError;
 		try {
 			try {

Propchange: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/AggregateClassLoading.out
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall?rev=382497&r1=382496&r2=382497&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/suites/derbylang.runall
Thu Mar  2 12:07:19 2006
@@ -2,6 +2,7 @@
 jdbcapi/metadataMultiConn.java
 jdbcapi/odbc_metadata.java
 lang/AIjdbc.java
+lang/AggregateClassLoading.java
 lang/CharUTF8.java
 lang/ConcurrentImplicitCreateSchema.java
 lang/DB2IsolationLevels.sql

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AggregateClassLoading.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AggregateClassLoading.java?rev=382497&r1=382496&r2=382497&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AggregateClassLoading.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AggregateClassLoading.java
Thu Mar  2 12:07:19 2006
@@ -56,7 +56,6 @@
 		// Find the location of the code for the Derby connection.
 		// The rest of the engine will be at the same location!
 		URL derbyURL = conn.getClass().getProtectionDomain().getCodeSource().getLocation();
-		System.out.println("derbyURL" + derbyURL.toExternalForm());
 		
 		// Create a new loader that loads from the same location as the engine.
 		// Create it without a parent, otherwise the parent
@@ -82,6 +81,7 @@
 		testAggregate(s, "select COUNT(i) from t");
 		testAggregate(s, "select COUNT(*) from t");
 		
+        s.execute("drop table t");
 	    s.close();
 		conn.close();
 		



Mime
View raw message