There are 2 code pieces to this. First is in org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl#afterCompletion which is the target of the JTA registered sync callbacks via simple delegation. I propose that method look like:
SynchronizationCallbackCoordinatorImpl.java
class SynchronizationCallbackCoordinatorImpl implements SynchronizationCallbackCoordinator {
privateint registrationThreadId;
privateint delayedCompletionHandlingStatus;
...
public SynchronizationCallbackCoordinatorImpl(TransactionCoordinator transactionCoordinator) {
...
registrationThreadId = Thread.currentThread().getId();
}
public void reset() {
...
delayedCompletionHandlingStatus = Status.NO_STATUS
}
public void afterCompletion(int status) {
if ( isNonRegistrationThread() ) {
// for callbacks coming from a thread different than the one used for registration,
// we need to delay the completion handling
delayedCompletionHandlingStatus = status;
}
else {
// otherwise, we do the completion handling immediately
doAfterCompletion( status );
}
}
privateboolean isNonRegistrationThread() {
return registrationThreadId == Thread.currentThread().getId();
}
private void doAfterCompletion(int status) {
...
try {
afterCompletionAction.doAction( transactionCoordinator, status );
transactionCoordinator.afterTransaction( null, status );
}
finally {
reset();
if ( transactionContext().shouldAutoClose() && !transactionContext().isClosed() ) {
LOG.trace( "Automatically closing session" );
transactionContext().managedClose();
}
}
}
Then, as stated above. the second piece is to tie into the Session method calls. Again, 2 options here. First is to hook in to the entry into the Session calls. This option performs the delayed handling until the next time the user calls into the Session; and the hooks for this option are already in place - see org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl#pulse. The other option is to hook in to the exit from the Session calls, which performs the delayed handling as we return from the methods that were processing when a timeout occurred. And we might very well need both.
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
To centralize discussions for clarity...
There are 2 code pieces to this. First is in org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorImpl#afterCompletion which is the target of the JTA registered sync callbacks via simple delegation. I propose that method look like:
Then, as stated above. the second piece is to tie into the Session method calls. Again, 2 options here. First is to hook in to the entry into the Session calls. This option performs the delayed handling until the next time the user calls into the Session; and the hooks for this option are already in place - see org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl#pulse. The other option is to hook in to the exit from the Session calls, which performs the delayed handling as we return from the methods that were processing when a timeout occurred. And we might very well need both.