commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1691861 - in /commons/proper/dbcp/trunk/src: changes/ main/java/org/apache/commons/dbcp2/ test/java/org/apache/commons/dbcp2/managed/
Date Sun, 19 Jul 2015 23:15:15 GMT
Author: psteitz
Date: Sun Jul 19 23:15:15 2015
New Revision: 1691861

URL: http://svn.apache.org/r1691861
Log:
Added null check to DelegatingConnection#closeInternal. Prior to this change, NPEs were being
generated by ManagedConnection#close.

JIRA: DBCP-438

Modified:
    commons/proper/dbcp/trunk/src/changes/changes.xml
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java

Modified: commons/proper/dbcp/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1691861&r1=1691860&r2=1691861&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbcp/trunk/src/changes/changes.xml Sun Jul 19 23:15:15 2015
@@ -61,6 +61,9 @@ The <action> type attribute can be add,u
 
   <body>
     <release version="2.1.1" date="TBD" description="Bug fixes.">
+      <action issue="DBCP-438" dev="psteitz" type="fix" due-to="Raihan Kibria">
+        Nested connections in a transaction (local) throws null pointer. 
+      </action>
       <action issue="DBCP-437" dev="psteitz" type="fix">
         BasicDataSource does not set disconnectionSql properties on its PoolableConnectionFactory.
       </action>

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java?rev=1691861&r1=1691860&r2=1691861&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
Sun Jul 19 23:15:15 2015
@@ -231,9 +231,13 @@ public class DelegatingConnection<C exte
         try {
             passivate();
         } finally {
-            try {
-                _conn.close();
-            } finally {
+            if (_conn != null) {
+                try {
+                    _conn.close();
+                } finally {
+                    _closed = true;
+                }
+            } else {
                 _closed = true;
             }
         }

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java?rev=1691861&r1=1691860&r2=1691861&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
Sun Jul 19 23:15:15 2015
@@ -242,4 +242,20 @@ public class TestManagedDataSource exten
         assertTrue(con2.innermostDelegateEquals(inner));
         assertFalse(con.equals(con2));
     }
+    
+    @Test
+    public void testNestedConnections() throws Exception {
+        transactionManager.begin();
+        
+        Connection c1 = null;
+        Connection c2 = null;
+        
+        c1 = newConnection();
+        c2 = newConnection();
+        
+        transactionManager.commit();
+        
+        c1.close();
+        c2.close();
+    }   
 }

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java?rev=1691861&r1=1691860&r2=1691861&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
Sun Jul 19 23:15:15 2015
@@ -70,6 +70,12 @@ public class TestManagedDataSourceInTx e
         // two connections to the same datasource are supposed to share
         // a single connection
     }
+    
+    @Override
+    @Test
+    public void testNestedConnections() {
+        // Not supported
+    }
 
     @Override
     @Test



Mime
View raw message