Issue Details (XML | Word | Printable)

Key: DBCP-245
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Michael Drechsel
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons Dbcp

SharedPoolDataSource saves wrong password forever

Created: 10/Oct/07 01:18 PM   Updated: 25/Mar/08 08:11 AM
Return to search
Component/s: None
Affects Version/s: 1.1, 1.2, 1.2.1, 1.2.2
Fix Version/s: 1.3

Time Tracking:
Not Specified

Environment:
Use of SharedPoolDataSource see sample code

if (privSharedDS == null)
{
privConPoolDS = new PGConnectionPoolDataSource();
privConPoolDS.setServerName(privServerName);
privConPoolDS.setDatabaseName(privServerDB);
privConPoolDS.setUser(privUser);
privConPoolDS.setPassword(privPassword);
// --------------------------------------
// dbcp caching via SharedPoolDataSource
// --------------------------------------
privSharedDS = new SharedPoolDataSource();
privSharedDS.setConnectionPoolDataSource(privConPoolDS);
privSharedDS.setMaxActive(10); // 0 = no limit
privSharedDS.setMaxIdle(10);
privSharedDS.setMinEvictableIdleTimeMillis(1000);
privSharedDS.setMaxWait(1000); // -1 = no limit
privSharedDS.setTimeBetweenEvictionRunsMillis(1000);
privSharedDS.setTestWhileIdle(true);
}
// --------------------------------------
// dbcp caching via SharedPoolDataSource
// --------------------------------------
tmpCon = privSharedDS.getConnection(privUser, privPassword);


Resolution Date: 29/Jan/08 02:30 AM


 Description  « Hide
The SharedPoolDataSource saves wrong password forever

1. Get a connection for user1 (use username of user1 and password of user1) ---> connection ok
2. Get a connection for user2 (use username of user2 and a wrong password) --> connection failed
3. Get a connection for user2 (use username of user2 and password of user2) --> connection will be failed too because the wrong password is stored in the usersKey map.

Bugfix
===================================================================

protected synchronized PooledConnectionAndInfo
getPooledConnectionAndInfo(String username, String password)
throws SQLException {
if (pool == null) {
try { registerPool(username, password); } catch (NamingException e) { throw new SQLNestedException("RegisterPool failed", e); }
}

PooledConnectionAndInfo info = null;
UserPassKey userPassKey = null;
try { userPassKey = getUserPassKey(username, password); info = (PooledConnectionAndInfo) pool .borrowObject(userPassKey); }
catch (Exception e) {

if (userKeys != null && userKeys.containsKey(username)) { userKeys.remove(username); }

throw new SQLNestedException(
"Could not retrieve connection info from pool", e);
}
return info;
}



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Phil Steitz made changes - 12/Oct/07 12:09 AM
Field Original Value New Value
Affects Version/s 1.1 [ 12311719 ]
Fix Version/s 1.3 [ 12311977 ]
Affects Version/s 1.2 [ 12311721 ]
Affects Version/s 1.2.1 [ 12311975 ]
Phil Steitz made changes - 29/Jan/08 02:30 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Henri Yandell made changes - 25/Mar/08 08:11 AM
Status Resolved [ 5 ] Closed [ 6 ]