commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r385251 - in /jakarta/commons/proper/dbcp/trunk: src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java xdocs/changes.xml
Date Sun, 12 Mar 2006 05:35:09 GMT
Author: psteitz
Date: Sat Mar 11 21:35:07 2006
New Revision: 385251

URL: http://svn.apache.org/viewcvs?rev=385251&view=rev
Log:
Inserted null check in close method of SharedPoolDataSource to avoid NPE
when invoked on non-initialized pool.
Addresses BZ #37359
Fix contributed by Jindrich Vimr.


Modified:
    jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
    jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
    jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java?rev=385251&r1=385250&r2=385251&view=diff
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
Sat Mar 11 21:35:07 2006
@@ -63,7 +63,9 @@
      * Close pool being maintained by this datasource.
      */
     public void close() throws Exception {
-        pool.close();
+        if (pool != null) {
+            pool.close();
+        }
         InstanceKeyObjectFactory.removeInstance(instanceKey);
     }
 

Modified: jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java?rev=385251&r1=385250&r2=385251&view=diff
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
Sat Mar 11 21:35:07 2006
@@ -265,6 +265,18 @@
             c[i].close();
         }
     }
+    
+    /**
+     * Test pool close.  Illustrates BZ 37359.
+     * 
+     * @throws Exception
+     */
+    public void testClosePool() throws Exception {
+      ((SharedPoolDataSource)ds).close();
+      SharedPoolDataSource tds = new SharedPoolDataSource();
+      // NPE before BZ 37359 fix 
+      tds.close();
+    }
 
     public void testMaxActive() 
         throws Exception 

Modified: jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml?rev=385251&r1=385250&r2=385251&view=diff
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml Sat Mar 11 21:35:07 2006
@@ -52,6 +52,10 @@
         concrete factory and added implementations of getReference in concrete
         subclasses.
       </action>
+      <action dev="psteitz" type="fix" issue="#37359" due-to="Jindrich Vimr">
+        Inserted null check in close method of SharedPoolDataSource to avoid
+        NPE when invoked on non-initialized pool.
+      </action>
     </release>   
   </body>
 </document>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message