You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/01/05 21:05:09 UTC

svn commit: r896195 - in /commons/proper/dbcp/trunk: src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java xdocs/changes.xml

Author: sebb
Date: Tue Jan  5 20:05:08 2010
New Revision: 896195

URL: http://svn.apache.org/viewvc?rev=896195&view=rev
Log:
DBCP-318 PerUserPoolDataSource.getPooledConnectionAndInfo multi-threading bug

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java
    commons/proper/dbcp/trunk/xdocs/changes.xml

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java?rev=896195&r1=896194&r2=896195&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/PerUserPoolDataSource.java Tue Jan  5 20:05:08 2010
@@ -364,8 +364,9 @@
         throws SQLException {
 
         PoolKey key = getPoolKey(username,password);
-        Object pool = pools.get(key);
+        Object pool;
         synchronized(this) {
+            pool = pools.get(key);
             if (pool == null) {
                 try {
                     registerPool(username, password);
@@ -498,7 +499,10 @@
                                   isRollbackAfterValidation(), 
                                   username, password);
            
-        pools.put(getPoolKey(username,password), pool);
+        Object old = pools.put(getPoolKey(username,password), pool);
+        if (old != null) {
+            throw new IllegalStateException("Pool already contains an entry for this user/password: "+username);
+        }
     }
 
     /**

Modified: commons/proper/dbcp/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/xdocs/changes.xml?rev=896195&r1=896194&r2=896195&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/xdocs/changes.xml (original)
+++ commons/proper/dbcp/trunk/xdocs/changes.xml Tue Jan  5 20:05:08 2010
@@ -49,6 +49,9 @@
      changes below since 1.2.2 applies to both the 1.3 and 1.4 release.  Other than
      the one issue related to adding JDBC 4 support (DBCP-191), all bug fixes
      or new features are included in both DBCP 1.3 and 1.4 ">
+      <action dev="sebb" type="fix" issue="DBCP-318" due-to="Sebastian Bazley">
+        PerUserPoolDataSource.getPooledConnectionAndInfo multi-threading bug.
+      </action>
       <action dev="sebb" type="fix" issue="DBCP-315" due-to="Sebastian Bazley">
         Remove throws clause from method that does not throw an exception.
       </action>