[ 
https://issues.apache.org/jira/browse/DBCP-569?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory resolved DBCP-569.
----------------------------------
    Fix Version/s: 2.9.0
       Resolution: Fixed

[~fguillaume]

In git master, please verify and close this ticket.

TY!

> Fix test random failure on 
> TestSynchronizationOrder.testInterposedSynchronization
> ---------------------------------------------------------------------------------
>
>                 Key: DBCP-569
>                 URL: https://issues.apache.org/jira/browse/DBCP-569
>             Project: Commons DBCP
>          Issue Type: Bug
>            Reporter: Florent Guillaume
>            Priority: Minor
>             Fix For: 2.9.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> {{TestSynchronizationOrder.testInterposedSynchronization}} may fail randomly 
> depending on GC behavior, because the test involves a {{Transaction}} object 
> held only be weak references, which may be cleared earlier that the test 
> expects:
> {noformat}
> java.sql.SQLException: Unable to enlist connection because the transaction 
> has been garbage collected
>       at 
> org.apache.commons.dbcp2.managed.TransactionContext.getTransaction(TransactionContext.java:186)
>       at 
> org.apache.commons.dbcp2.managed.TransactionContext.setSharedConnection(TransactionContext.java:105)
>       at 
> org.apache.commons.dbcp2.managed.ManagedConnection.updateTransactionStatus(ManagedConnection.java:310)
>       at 
> org.apache.commons.dbcp2.managed.ManagedConnection.<init>(ManagedConnection.java:89)
>       at 
> org.apache.commons.dbcp2.managed.ManagedDataSource.getConnection(ManagedDataSource.java:64)
>       at 
> org.apache.commons.dbcp2.managed.TestSynchronizationOrder.testInterposedSynchronization(TestSynchronizationOrder.java:118)
> {noformat}
> The {{TransactionContext.transactionRef}} and the 
> {{TransactionRegistry.caches}} are holding onto the {{Transaction}} (acquired 
> in {{TransactionRegistry.getActiveTransactionContext()}}) only using weak 
> refs.
> However in {{TestSynchronizationOrder}} the fake {{TransactionManager}} 
> returns a {{Transaction}} (that's an instance of an anonymous class) but 
> nobody holds a strong reference to that. The fake {{TransactionManager}} 
> should create the fake {{Transaction}} at {{begin()}} time, and hold onto it 
> using a strong reference until {{commit()}} time.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to