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();
            previous.incUseCount();
        } else {
            Configuration.logDebug ( this + ": creating connection proxy..." );
            ret = ( Reapable ) AtomikosThreadLocalConnection.newInstance ( this , props.getUniqueResourceName() );
        }
        return ret;
    }
    

Best regards,

--Stefan



CallStack for incrementing the useCount:

called from com.atomikos.jdbc.nonxa.AtomikosNonXAPooledConnection.doCreateConnectionProxy(AtomikosNonXAPooledConnection.java:101)
called from com.atomikos.datasource.pool.AbstractXPooledConnection.createConnectionProxy(AbstractXPooledConnection.java:72)
called from com.atomikos.datasource.pool.ConnectionPool.recycleConnectionIfPossible(ConnectionPool.java:106)
called from com.atomikos.datasource.pool.ConnectionPool.borrowConnection(ConnectionPool.java:135)
called from com.atomikos.jdbc.AbstractDataSourceBean.getConnection(AbstractDataSourceBean.java:313)
called from com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean.getConnection(AtomikosNonXADataSourceBean.java:207)
stefan wachter Send private email
Tuesday, January 20, 2009
 
 
Hi,

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
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