commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 33167] - [dbcp] Individual connection close method
Date Wed, 20 Jul 2005 20:55:20 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33167>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33167





------- Additional Comments From matt@thebishops.org  2005-07-20 22:55 -------
Some additional comments:

The pools member isn't a synchronized collection, so it is possible for pools.remove() to
cause a failure 
in other operations that use it, like get().  I recommend wrapping pool in a SynchronizedMap:

    private transient Map pools = Collections.synchronizedMap(new HashMap());


Additionally, it would be better to remove the ObjectPool from pools before closing it so
a follow-on 
thread can create a new pool for this user while the old pool is being closed down.  This
is a real 
possibility for the password-change scenario, as it may take some time for the pool to close
down 
before the user account is re-opened with the new credentials.

Here's the method we are using in production to solve this problem:

    /**
     * Close pool associated with this user.
     */
    public void close(String user) {
        PoolKey key = getPoolKey(user);
        ObjectPool pool = (ObjectPool) pools.remove(key);

        //is there a pool to be closed?
        if (pool == null) {
            return;
        }

        try {
            pool.close();
        } catch (Exception closePoolException) {
            //ignore
        }
    }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
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