Fix connection leak in connection provider used for JTA tests

This commit is contained in:
Christian Beikov 2021-02-03 11:11:37 +01:00
parent a8cddb93e8
commit 62d727d44e
1 changed files with 8 additions and 3 deletions

View File

@ -93,9 +93,14 @@ public class JtaAwareConnectionProviderImpl implements ConnectionProvider, Confi
if ( connection == null ) {
connection = delegate.getConnection();
TestingJtaPlatformImpl.synchronizationRegistry().putResource( CONNECTION_KEY, connection );
XAResourceWrapper xaResourceWrapper = new XAResourceWrapper( this, connection );
currentTransaction.enlistResource( xaResourceWrapper );
try {
XAResourceWrapper xaResourceWrapper = new XAResourceWrapper( this, connection );
currentTransaction.enlistResource( xaResourceWrapper );
}
catch (Exception e) {
delist( connection );
throw e;
}
}
return connection;
}