JtaTransaction doesn't call Synchronization methods correctly if it is the initiator

Description

If JtaTransaction is the initiator of the UserTransaction, when you register a synchronization it doesn't register a synchronization with the JtaPlatform (see TransactionCoordinatorImpl.java:227).

When the JtaTransaction commits, it commits the UserTransaction (as the JtaTransaction is the initiator of it), but afterTransactionCompletion(int status) in JtaTransaction is a noop, so the Synchronization is not called here.

The Synchronization is called by afterAfterCompletion() in JtaTransaction, passing the status of the UserTransaction. However at this time the UserTransaction has been committed and is now gone, so userTransaction.getStatus() returns STATUS_NO_TRANSACTION.

What I expect is for the Synchronization to be called with the STATUS_COMMITTED status (as this is what happened), however it is called with the STATUS_NO_TRANSACTION status.

Is this a fault? I have "remedied" it by sending completion notifications in afterTransactionCompletion(int status)... although this results in afterAfterCompletion() still reporting the STATUS_NO_TRANSACTION afterwards (unless I call transactionCoordinator().afterTransaction( this, status ); in afterTransactionCompletion(int status)... but I'm not sure whether I'm doing right!)

Activity

Show:

Steve EbersoleOctober 28, 2015 at 3:24 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Steve EbersoleOctober 27, 2015 at 7:15 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Steve EbersoleSeptember 24, 2015 at 3:39 PM

Please verify this affects 5.0 as well. 4.x is no longer maintained, and transaction handling underwent a major overhaul in 5.0

Karl von RandowSeptember 10, 2015 at 2:11 AM

Or perhaps afterAfterCompletion() should use the localStatus ivar instead of the status from the UserTransaction.

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created September 10, 2015 at 2:01 AM
Updated February 26, 2016 at 3:28 PM