From 6aaaf37d6f962b6d2afc810ead3676192748725f Mon Sep 17 00:00:00 2001 From: Radim Vansa Date: Mon, 21 Nov 2016 14:12:38 +0100 Subject: [PATCH] HHH-11267 Fix BulkOperationsTest and ReadWriteTest --- .../test/cache/infinispan/tm/XaConnectionProvider.java | 4 ++-- .../test/cache/infinispan/tm/XaTransactionImpl.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java index d44349d822..5597d43319 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaConnectionProvider.java @@ -75,7 +75,7 @@ public class XaConnectionProvider implements ConnectionProvider { Connection connection = currentTransaction.getEnlistedConnection(); if ( connection == null ) { connection = actualConnectionProvider.getConnection(); - currentTransaction.enlistConnection( connection ); + currentTransaction.enlistConnection( connection, actualConnectionProvider ); } return connection; } @@ -83,7 +83,7 @@ public class XaConnectionProvider implements ConnectionProvider { public void closeConnection(Connection conn) throws SQLException { if ( !isTransactional ) { - conn.close(); + actualConnectionProvider.closeConnection(conn); } } diff --git a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java index 31b5dcc70c..0d4f678e60 100644 --- a/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java +++ b/hibernate-infinispan/src/test/java/org/hibernate/test/cache/infinispan/tm/XaTransactionImpl.java @@ -25,6 +25,7 @@ import javax.transaction.xa.XAResource; import javax.transaction.xa.Xid; import org.hibernate.cache.infinispan.util.InfinispanMessageLogger; +import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider; /** * XaResourceCapableTransactionImpl. @@ -41,6 +42,7 @@ public class XaTransactionImpl implements Transaction { private final XaTransactionManagerImpl jtaTransactionManager; private List enlistedResources = new ArrayList(); private Xid xid = new XaResourceCapableTransactionXid(); + private ConnectionProvider connectionProvider; public XaTransactionImpl(XaTransactionManagerImpl jtaTransactionManager) { this.jtaTransactionManager = jtaTransactionManager; @@ -84,7 +86,8 @@ public class XaTransactionImpl implements Transaction { if (connection != null) { try { connection.commit(); - connection.close(); + connectionProvider.closeConnection(connection); + connection = null; } catch (SQLException sqle) { status = Status.STATUS_UNKNOWN; throw new SystemException(); @@ -147,11 +150,12 @@ public class XaTransactionImpl implements Transaction { synchronizations.add(synchronization); } - public void enlistConnection(Connection connection) { + public void enlistConnection(Connection connection, ConnectionProvider connectionProvider) { if (this.connection != null) { throw new IllegalStateException("Connection already registered"); } this.connection = connection; + this.connectionProvider = connectionProvider; } public Connection getEnlistedConnection() {