[dbcp] NullPointerException retrieving connection from the pool

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[dbcp] NullPointerException retrieving connection from the pool

Fedor Karpelevitch-3
Hi.

I filed this bug a while ago, but did not get any reaction.
Do you guys think my diagnosis of the problem is correct?

------------------------

under some load we start getting this exception when retrieving connection
from
pool:

org.apache.commons.dbcp.SQLNestedException: Could not retrieve connection
info
from pool
        at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnection
AndInfo(SharedPoolDataSource.java:169)
        at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst
anceKeyDataSource.java:631)
        at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(Inst
anceKeyDataSource.java:615)
        at
org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:705)
        ... 34 more
Caused by: java.lang.NullPointerException
        at
org.apache.commons.collections.SequencedHashMap.insertEntry(SequencedHashMap
.java:226)
        at
org.apache.commons.collections.SequencedHashMap.put(SequencedHashMap.java:45
1)
        at org.apache.commons.collections.LRUMap.put(LRUMap.java:125)
        at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getUserPassKey(Shar
edPoolDataSource.java:179)
        at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnection
AndInfo(SharedPoolDataSource.java:165)
        ... 37 more

this is apparently caused by improper syncronization:

SharedPoolDataSource.getPooledConnectionAndInfo() is synchronized _instance_
method, but it accesses SharedPoolDataSource.userKeys which is a _static_
variable, so if you have more than one instance of SharedPoolDataSource (as
we
do) access to the map would not be properly synchronized. So either map
should
be made instance variable, or the method should be synchronized on the
class,
not instance.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]