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,10 +93,15 @@ public class JtaAwareConnectionProviderImpl implements ConnectionProvider, Confi
if ( connection == null ) {
connection = delegate.getConnection();
TestingJtaPlatformImpl.synchronizationRegistry().putResource( CONNECTION_KEY, connection );
try {
XAResourceWrapper xaResourceWrapper = new XAResourceWrapper( this, connection );
currentTransaction.enlistResource( xaResourceWrapper );
}
catch (Exception e) {
delist( connection );
throw e;
}
}
return connection;
}
catch (SQLException e) {