HHH-9312 - Database connection leak with JTA transaction tracking and background thread not releasing database connection

(cherry picked from commit 9e1afbaf49)
This commit is contained in:
Steve Ebersole 2014-08-04 13:32:51 -05:00
parent a0663f0d6c
commit 72e9645d4b
2 changed files with 8 additions and 0 deletions

View File

@ -63,6 +63,10 @@ public class SynchronizationCallbackCoordinatorNonTrackingImpl implements Synchr
afterCompletionAction = STANDARD_AFTER_COMPLETION_ACTION;
}
protected final TransactionCoordinator transactionCoordinator() {
return transactionCoordinator;
}
private TransactionContext transactionContext() {
return transactionCoordinator.getTransactionContext();
}

View File

@ -78,6 +78,10 @@ public class SynchronizationCallbackCoordinatorTrackingImpl extends Synchronizat
// check for it in SessionImpl. See HHH-7910.
delayedCompletionHandlingStatus = status;
// no matter what we need to release the Connection. Not releasing
// the Connection here can lead to leaked Connections.
transactionCoordinator().getJdbcCoordinator().getLogicalConnection().close();
log.rollbackFromBackgroundThread( status );
return;
}