Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-100

[dbcp] NullPointerException retrieving connection from the pool

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2.2
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: Other

    • Bugzilla Id:
      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fedor.karpelevitch@mscibarra.com Fedor Karpelevitch
            • Votes:
              3 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: