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

[dbcp] NullPointerException retrieving connection from the pool

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.2.2
    • 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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            fedor.karpelevitch@mscibarra.com Fedor Karpelevitch
            Votes:
            3 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment