BTM
  1. BTM
  2. BTM-60

NullPointerException in XAPool.containsXAResourceHolderMatchingGtrid()

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.3
    • Fix Version/s: 2.0.0
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      1

      Description

      While testing BTM on a somewhat slow server, we noticed a NullPointerException in XAPool.containsXAResourceHolderMatchingGtrid() that was breaking stuff.
      It seems like nobody was checking if bitronixXid was null before calling a method on it.

      I've included a patch which I believe fixes this problem but I'm not completely sure if it is the correct action to take because I don't know how BTM works. Essentially, if bitronixXid is null, it just skips that resource instead of causing a NullPointerException.

      Here's the relevant stack trace:

      Caused by: java.sql.SQLException: unable to get a connection from pool of a PoolingDataSource containing an XAPool of resource jdbc/DS with 5 connection(s) (3 still available)
      at bitronix.tm.resource.jdbc.PoolingDataSource.getConnection(PoolingDataSource.java:109)
      at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:92)
      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
      ... 144 more
      Caused by: java.lang.NullPointerException
      at bitronix.tm.resource.common.XAPool.containsXAResourceHolderMatchingGtrid(XAPool.java:305)
      at bitronix.tm.resource.common.XAPool.getNotAccessible(XAPool.java:286)
      at bitronix.tm.resource.common.XAPool.getConnectionHandle(XAPool.java:96)
      at bitronix.tm.resource.common.XAPool.getConnectionHandle(XAPool.java:71)
      at bitronix.tm.resource.jdbc.PoolingDataSource.getConnection(PoolingDataSource.java:105)
      ... 146 more

        Activity

        Hide
        Ludovic Orban added a comment -

        Indeed, there is a race condition that can happen when the connection recycling algorithm runs.

        Your proposed patch is fine so I integrated it.

        Thanks for the report!

        Show
        Ludovic Orban added a comment - Indeed, there is a race condition that can happen when the connection recycling algorithm runs. Your proposed patch is fine so I integrated it. Thanks for the report!

          People

          • Assignee:
            Ludovic Orban
            Reporter:
            Jordan Yelloz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: