db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From myrn...@apache.org
Subject svn commit: r711266 - in /db/derby/code/trunk/java: build/org/apache/derbyBuild/ client/org/apache/derby/client/net/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Date Tue, 04 Nov 2008 14:57:51 GMT
Author: myrnavl
Date: Tue Nov  4 06:57:51 2008
New Revision: 711266

URL: http://svn.apache.org/viewvc?rev=711266&view=rev
Log:
DERBY-2498; fix NullPointerException in clientDataSource.getConnection and ClientConnectionPoolDataSource.getConnection
when the databaseName is invalid.

Modified:
    db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java

Modified: db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java?rev=711266&r1=711265&r2=711266&view=diff
==============================================================================
--- db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java (original)
+++ db/derby/code/trunk/java/build/org/apache/derbyBuild/splitmessages.java Tue Nov  4 06:57:51
2008
@@ -118,6 +118,7 @@
         clientMessageIds.add(SQLState.NET_VCM_VCS_LENGTHS_INVALID);
         clientMessageIds.add(SQLState.LANG_STRING_TOO_LONG);
         clientMessageIds.add(SQLState.INVALID_COLUMN_ARRAY_LENGTH);
+        clientMessageIds.add(SQLState.PROPERTY_INVALID_VALUE);
     }
 
 	public static void main(String[] args) throws Exception {

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java?rev=711266&r1=711265&r2=711266&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection.java Tue Nov
 4 06:57:51 2008
@@ -33,6 +33,7 @@
 import org.apache.derby.shared.common.i18n.MessageUtil;
 import org.apache.derby.client.am.Statement;
 import org.apache.derby.client.am.Utils;
+import org.apache.derby.iapi.reference.Attribute;
 import org.apache.derby.jdbc.ClientBaseDataSource;
 import org.apache.derby.jdbc.ClientDriver;
 import org.apache.derby.client.ClientPooledConnection;
@@ -299,8 +300,19 @@
         this.rmId_ = rmId;
         this.isXAConnection_ = isXAConn;
         flowConnect(password, securityMechanism_);
-        completeConnect();
-
+        // it's possible that the internal Driver.connect() calls returned null,
+        // thus, a null connection, e.g. when the databasename has a : in it
+        // (which the InternalDriver assumes means there's a subsubprotocol)  
+        // and it's not a subsubprotocol recognized by our drivers.
+        // If so, bail out here.
+        if(!isConnectionNull())
+            completeConnect();
+        else
+        {
+            agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
+                    new ClientMessageId(SQLState.PROPERTY_INVALID_VALUE),
+                    Attribute.DBNAME_ATTR,databaseName_));
+        }
     }
 
     // preferably without password in the method signature.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java?rev=711266&r1=711265&r2=711266&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
Tue Nov  4 06:57:51 2008
@@ -103,6 +103,7 @@
         suite.addTest(new DataSourceTest("testBadConnectionAttributeSyntax"));
         suite.addTest(new DataSourceTest("testDescriptionProperty"));
         suite.addTest(new DataSourceTest("testAllDataSources"));
+        suite.addTest(new DataSourceTest("testJira95ds"));
         return suite;
     }
 
@@ -130,8 +131,6 @@
     private static Test getEmbeddedSuite(String postfix) {
         TestSuite suite = new TestSuite("Embedded" + postfix);
         suite.addTest(new DataSourceTest("testDSRequestAuthentication"));
-        // when DERBY-2498 gets fixed, move this one to baseSuite
-        suite.addTest(new DataSourceTest("testJira95ds"));
         return suite;
     }
     
@@ -231,15 +230,9 @@
             ds.getConnection();
             fail ("expected an SQLException!");
         } catch (SQLException sqle) {
-            // DERBY-2498: with client, getting a NullPointerException.
-            // Note also: the NPE does not occur with XADataSource - see
-            // testJira95xads().
-            if (usingEmbedded())
-                assertSQLState("XCY00", sqle);
+            assertSQLState("XCY00", sqle);
         } catch (Exception e) {
-            // DERBY-2498, when fixed, remove 'if'
-            if (usingEmbedded())
-                fail ("unexpected exception: " + e.toString());
+            fail ("unexpected exception: " + e.toString());
         }
     } 
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java?rev=711266&r1=711265&r2=711266&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Tue Nov  4 06:57:51 2008
@@ -134,6 +134,7 @@
         TestSuite suite = new TestSuite("ClientAndEmbedded" + postfix);
         suite.addTest(new J2EEDataSourceTest("testGlobalLocalInterleaf"));
         suite.addTest(new J2EEDataSourceTest("testSetIsolationWithStatement"));
+        suite.addTest(new J2EEDataSourceTest("testJira95pds"));
         suite.addTest(new J2EEDataSourceTest("testJira95xads"));
         suite.addTest(new J2EEDataSourceTest("testBadConnectionAttributeSyntax"));
         suite.addTest(new J2EEDataSourceTest("testCloseActiveConnection_DS"));
@@ -183,8 +184,6 @@
     private static Test getEmbeddedSuite(String postfix) {
         TestSuite suite = new TestSuite("Embedded" + postfix);
         suite.addTest(new J2EEDataSourceTest("testDSRequestAuthentication"));
-        // when DERBY-2498 gets fixed, move this one to baseSuite
-        suite.addTest(new J2EEDataSourceTest("testJira95pds"));
         // Following cannot run with client because of DERBY-2533; it hangs
         // when fixed, this can be moved to baseSuite.
         suite.addTest(new J2EEDataSourceTest("testReuseAcrossGlobalLocal"));
@@ -2203,13 +2202,9 @@
             pds.getPooledConnection();
             fail ("expected an SQLException!");
         } catch (SQLException sqle) {
-            // DERBY-2498 - when fixed, remove if
-            if (usingEmbedded())
-                assertSQLState("XCY00", sqle);
+            assertSQLState("XCY00", sqle);
         } catch (Exception e) {
-            // DERBY-2498 - when fixed, remove if
-            if (usingEmbedded())
-                throw e;
+            throw e;
         }
     }
     



Mime
View raw message