You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Phil Steitz (JIRA)" <ji...@apache.org> on 2014/05/31 06:04:02 UTC
[jira] [Closed] (DBCP-378) ManagedDataSource returns uses the same
underlying DB connection across JTA tx
[ https://issues.apache.org/jira/browse/DBCP-378?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz closed DBCP-378.
----------------------------
> ManagedDataSource returns uses the same underlying DB connection across JTA tx
> ------------------------------------------------------------------------------
>
> Key: DBCP-378
> URL: https://issues.apache.org/jira/browse/DBCP-378
> Project: Commons Dbcp
> Issue Type: Bug
> Affects Versions: 1.4
> Reporter: Ortwin Glück
> Priority: Critical
>
> It seems that when more than one JTA transaction is used within the same thread (suspend/resume transaction), the ManagedDataSource always uses the same underlying DB connection. This scenario is common in EJB containers! If the same DB connection is used the JTA suspend/resume actions have no effect. The JTA semantics is violated this behaviour.
> Use the following code to setup a unit test that works in your environment
> // DS setup
> XADataSource ods = new oracle.jdbc.xa.client.OracleXADataSource();
> ...
> TransactionManager tm = ...
> DataSourceXAConnectionFactory cf = new DataSourceXAConnectionFactory(tm, ods);
>
> AbandonedConfig ab = new AbandonedConfig();
> ab.setLogAbandoned(false);
> ab.setRemoveAbandoned(true);
> ab.setRemoveAbandonedTimeout(15*60);
>
> connPool = new GenericObjectPool(null);
>
> // registers itself on the pool
> KeyedObjectPoolFactory stmtPool = = new StackKeyedObjectPoolFactory(5);
> new PoolableManagedConnectionFactory(cf, connPool, stmtPool,
> null, 5,
> (Collection<String>) null, // init sql
> false, // read-only
> false, // auto-commit
> Connection.TRANSACTION_READ_COMMITTED,
> (String) null, // catalog
> ab);
> ds = new ManagedDataSource(connPool, cf.getTransactionRegistry());
> // Unit test
> tm.begin();
> Connection c1 = source.getConnection();
> Connection ic1 = ((ManagedConnection) c1).getInnermostDelegate();
> c1.close();
>
> Transaction tx = tm.suspend();
> tm.begin();
> c2 = source.getConnection();
> ic2 = ((ManagedConnection) c2).getInnermostDelegate();
> c2.close();
>
> assertNotSame("Pool must NOT use identical connection across tx", ic1, ic2);
> tm.commit();
> tm.resume(tx);
> tm.commit();
--
This message was sent by Atlassian JIRA
(v6.2#6252)