Atomikos Forum

useCount incremented twice when reusing exisiting conn. proxy

Hi all!

When the method AtomikosNonXADataSourceBean.getConnection() gets a reusable connection at line 207 then the useCount of that connection is already incremented in AtomikosNonXAPooledConnection.doCreateConnectionProxy (line  101). (See call stack below.)

Later on line 213 of AtomikosNonXADataSourceBean.getConnection() the useCount of that connection is incremented a second time.

This causes the returned connection to be never reusable because its useCount is decremented only once.

I guess that the bug is located in AtomikosNonXAPooledConnection where the use count should not be incremented in case of a recycled connection:

    protected Reapable doCreateConnectionProxy ( HeuristicMessage hmsg ) throws Exception
        Reapable ret = null;
        if ( canBeRecycledForCallingThread() ) {
            Configuration.logDebug ( this + ": reusing existing proxy for thread..." );
            ret = getCurrentConnectionProxy();
// remove the following three lines
            DynamicProxy dproxy = ( DynamicProxy ) ret;
            AtomikosThreadLocalConnection previous = (AtomikosThreadLocalConnection) dproxy.getInvocationHandler();
        } else {
            Configuration.logDebug ( this + ": creating connection proxy..." );
            ret = ( Reapable ) AtomikosThreadLocalConnection.newInstance ( this , props.getUniqueResourceName() );
        return ret;

Best regards,


CallStack for incrementing the useCount:

called from com.atomikos.jdbc.nonxa.AtomikosNonXAPooledConnection.doCreateConnectionProxy(
called from com.atomikos.datasource.pool.AbstractXPooledConnection.createConnectionProxy(
called from com.atomikos.datasource.pool.ConnectionPool.recycleConnectionIfPossible(
called from com.atomikos.datasource.pool.ConnectionPool.borrowConnection(
called from com.atomikos.jdbc.AbstractDataSourceBean.getConnection(
called from com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean.getConnection(
stefan wachter Send private email
Tuesday, January 20, 2009

Yes, this seems like a bug. Thanks for the feedback, I created an issue for the 3.5.1 release due to come out soon.

Guy Pardon Send private email
Wednesday, January 21, 2009

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics