db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r650814 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Date Wed, 23 Apr 2008 10:15:17 GMT
Author: kristwaa
Date: Wed Apr 23 03:15:11 2008
New Revision: 650814

URL: http://svn.apache.org/viewvc?rev=650814&view=rev
Log:
DERBY-3431: DatabaseMetaData.getConnection returns the wrong connection when using connection
pooling.
Added a test case exposing the bug where DatabaseMetaData.getConnection returns a reference
to a connection it should not publish.
Note that the test is disabled, because the bug is still at large.
Patch file: derby-3431-2a-test.diff

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java

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=650814&r1=650813&r2=650814&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
Wed Apr 23 03:15:11 2008
@@ -26,6 +26,7 @@
 import java.security.AccessController;
 import java.sql.CallableStatement;
 import java.sql.Connection;
+import java.sql.DatabaseMetaData;
 import java.sql.DriverManager;
 import java.sql.ParameterMetaData;
 import java.sql.PreparedStatement;
@@ -2684,6 +2685,37 @@
         // END XA HOLDABILITY TEST");
     }
     
+    /**
+     * Tests that DatabaseMetaData.getConnection does not leak references to
+     * physical connections or other logical connections.
+     *
+     * @throws SQLException if something goes wrong
+     */
+    // Disabled because the test fails. It fails in different ways for client
+    // and embedded. See DERBY-3431 for information.
+    // To enable, remove 'DISABLED_' from the method name and add the test
+    // to the appropriate suite (i.e. baseSuite).
+    public void DISABLED_testConnectionLeakInDatabaseMetaData()
+            throws SQLException {
+        ConnectionPoolDataSource cpDs =
+                J2EEDataSource.getConnectionPoolDataSource();
+        PooledConnection pc = cpDs.getPooledConnection();
+        // Get first logical connection and a meta data object.
+        Connection con1 = pc.getConnection();
+        DatabaseMetaData dmd1 = con1.getMetaData();
+        assertSame(con1, dmd1.getConnection());
+        con1.close();
+        // Get second logical connection and a meta data object.
+        Connection con2 = pc.getConnection();
+        DatabaseMetaData dmd2 = con2.getMetaData();
+        con2.close();
+        pc.close();
+        // The first meta data object should not return a reference to the
+        // second logical connection.
+        assertSame(con2, dmd2.getConnection());
+        assertNotSame(con2, dmd1.getConnection());
+    }
+
     /**
      * Tests for DERBY-1144
      * 



Mime
View raw message