commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r758284 - in /commons/proper/dbcp/trunk/src: java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java java/org/apache/commons/dbcp/datasources/UserPassKey.java test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
Date Wed, 25 Mar 2009 14:55:29 GMT
Author: markt
Date: Wed Mar 25 14:55:25 2009
New Revision: 758284

URL: http://svn.apache.org/viewvc?rev=758284&view=rev
Log:
Fix DBCP-8. Handle changed passwords in SharedPoolDataSource.
Patch provided by Michael T. Dean

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/UserPassKey.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java?rev=758284&r1=758283&r2=758284&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/SharedPoolDataSource.java
Wed Mar 25 14:55:25 2009
@@ -194,10 +194,11 @@
     }
     
     private UserPassKey getUserPassKey(String username, String password) {
-        UserPassKey key = (UserPassKey) userKeys.get(username);
+        String name = username + password;
+        UserPassKey key = (UserPassKey) userKeys.get(name);
         if (key == null) {
             key = new UserPassKey(username, password);
-            userKeys.put(username, key);
+            userKeys.put(name, key);
         }
         return key;
     }

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/UserPassKey.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/UserPassKey.java?rev=758284&r1=758283&r2=758284&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/UserPassKey.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/datasources/UserPassKey.java
Wed Mar 25 14:55:25 2009
@@ -82,7 +82,8 @@
     }
 
     public int hashCode() {
-        return (this.username != null ? this.username.hashCode() : 0);
+        return (this.username != null ?
+                (this.username + this.password).hashCode() : 0);
     }
 
     public String toString() {

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java?rev=758284&r1=758283&r2=758284&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
Wed Mar 25 14:55:25 2009
@@ -27,6 +27,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.commons.dbcp.SQLNestedException;
 import org.apache.commons.dbcp.TestConnectionPool;
 import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
 
@@ -102,9 +103,10 @@
             ds.getConnection("u1", "x").close();
             fail("Able to retrieve connection with incorrect password");
         }
-        catch (SQLException e)
+        catch (SQLNestedException e)
         {
-            if (!e.getMessage().startsWith("Given password did not match")) 
+            Throwable t = e.getCause();
+            if (!t.getMessage().startsWith("x is not the correct password"))
             {
                 throw e;
             }



Mime
View raw message