Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
Operating System: Windows XP
Platform: Other
-
35825
Description
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.getPooledConnectionAndInfo(SharedPoolDataSource.java:169)
at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(InstanceKeyDataSource.java:631)
at
org.apache.commons.dbcp.datasources.InstanceKeyDataSource.getConnection(InstanceKeyDataSource.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:451)
at org.apache.commons.collections.LRUMap.put(LRUMap.java:125)
at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getUserPassKey(SharedPoolDataSource.java:179)
at
org.apache.commons.dbcp.datasources.SharedPoolDataSource.getPooledConnectionAndInfo(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.