Skip to content

In a multithreaded environment, AtomikosConnectionProxy.newInstance may throw a java.lang.NullPointerException. #245

@ItsKaiiiiiiii

Description

@ItsKaiiiiiiii

Describe the bug
The Atomikos background thread periodically destroys connections that have exceeded their maximum lifetime. If another thread frequently accesses the database to create connections, it will encounter a null pointer error when creating the thread.

To Reproduce
Steps to reproduce the behavior:

  1. set MinPoolSize = 1 and MaxPoolSize=2 MaxLifeTime=3,ReapTimeOut=0。env:SpringBoot3+JDK17+Atomikos+Druid+@SchedulerLock+Mysql
  2. I encountered a null pointer exception, with the error message: “Cannot invoke ‘Object.getClass()’ because ‘c’ is null.”
  3. This exception should not occur in a multithreaded environment.
  4. I Use transactions-spring-boot-starter,version is 5.0.9

Additional context
Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "c" is null
at com.atomikos.jdbc.AtomikosConnectionProxy.newInstance(AtomikosConnectionProxy.java:246)
at com.atomikos.jdbc.AtomikosXAPooledConnection.doCreateConnectionProxy(AtomikosXAPooledConnection.java:93)
at com.atomikos.datasource.pool.AbstractXPooledConnection.createConnectionProxy(AbstractXPooledConnection.java:56)
at com.atomikos.datasource.pool.ConnectionPoolWithConcurrentValidation.concurrentlyTryToUse(ConnectionPoolWithConcurrentValidation.java:59)
at com.atomikos.datasource.pool.ConnectionPoolWithConcurrentValidation.retrieveFirstAvailableConnection(ConnectionPoolWithConcurrentValidation.java:41)
at com.atomikos.datasource.pool.ConnectionPool.retrieveFirstAvailableConnectionAndGrowPoolIfNecessary(ConnectionPool.java:153)
at com.atomikos.datasource.pool.ConnectionPool.findOrWaitForAnAvailableConnection(ConnectionPool.java:141)
at com.atomikos.datasource.pool.ConnectionPool.borrowConnection(ConnectionPool.java:132)
at com.atomikos.jdbc.AbstractDataSourceBean.getConnection(AbstractDataSourceBean.java:346)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:269)
... 31 common frames omitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions