Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-3614

NPE when validating database connection (and the validation failed) if connection pool statistics is enabled

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • 7.0.0.ER7
    • 7.0.0.ER6
    • JCA
    • None
    • Workaround Exists
    • Hide

      Use mcp="org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool"

      Show
      Use mcp="org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool"
    • Hide
      xa-data-source add --name=TestXADS --jndi-name=java:jboss/datasources/TestXADS --driver-name=h2 --validate-on-match=true --statistics-enabled=true --valid-connection-checker-class-name="org.jboss.jca.adapters.jdbc.extensions.novendor.SQLExceptionValidConnectionChecker" --xa-datasource-class="org.h2.jdbcx.JdbcDataSource" --user-name=sa --password=sa --min-pool-size=1 --max-pool-size=1 --pool-prefill=true --xa-datasource-properties=URL=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
      /subsystem=datasources/xa-data-source=TestXADS:test-connection-in-pool
      
      Show
      xa-data-source add --name=TestXADS --jndi-name=java:jboss/datasources/TestXADS --driver-name=h2 --validate-on-match= true --statistics-enabled= true --valid-connection-checker- class- name= "org.jboss.jca.adapters.jdbc.extensions.novendor.SQLExceptionValidConnectionChecker" --xa-datasource-class= "org.h2.jdbcx.JdbcDataSource" --user-name=sa --password=sa --min-pool-size=1 --max-pool-size=1 --pool-prefill= true --xa-datasource-properties=URL=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE /subsystem=datasources/xa-data-source=TestXADS:test-connection-in-pool

      • An xa-datasource connection pool is configured with: statistic-enabled=true, validate-on-match=true
      • When validation failed, after the failure, the following is logged:
      2016-02-10 12:23:12,580 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (Sched1_Worker-13) IJ000621: Destroying connection that could not be validated: null
      
      • This appears to come from SemaphoreConcurrentLinkedDequeManagedConnectionPool.java, line 436:
        log.destroyingConnectionNotValidated(clw.getConnectionListener());
        
      • So apparently clw.getConnectionListener() is null at this point, causing line 441/442 to throw NPE, if statistics is enabled:
      pool.getInternalStatistics().deltaTotalPoolTime(lastUsed - clw.getConnectionListener().getLastReturnedTime());
      
      • NPE is caught by the catch clause, and line 456 write the following to the log:
      2016-02-10 12:23:12,580 WARN  [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (Sched1_Worker-13) IJ000613: Throwable while trying to match managed connection, destroying connection: null: java.lang.NullPointerException
      	at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:441)
      	at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getTransactionNewConnection(AbstractPool.java:708)
      	at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:607)
      	at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:590)
      	at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:429)
      	at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:747)
      
      • However, this catch clause try to do the same thing that cause the NPE in line 461/462
        pool.getInternalStatistics().deltaTotalPoolTime(lastUsed - clw.getConnectionListener().getLastReturnedTime());
        
      • And finally this NPE is throw all the way out to the user of the connection

              jpederse@redhat.com Jesper Pedersen
              msimka@redhat.com Martin Simka
              Martin Simka Martin Simka
              Martin Simka Martin Simka
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: