From c72e89cadbd5782cd61005827be438a9a5f18fa4 Mon Sep 17 00:00:00 2001 From: liuyangming Date: Fri, 20 Jan 2017 12:43:13 +0800 Subject: [PATCH] =?UTF-8?q?*=20=E5=BB=B6=E8=BF=9F=E7=89=A9=E7=90=86?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E7=9A=84=E5=85=B3=E9=97=AD=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../supports/jdbc/LocalXAConnection.java | 17 ++++------------- .../bytejta/supports/jdbc/LocalXAResource.java | 6 +++--- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXAConnection.java b/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXAConnection.java index c70fa37..bb2c69f 100644 --- a/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXAConnection.java +++ b/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXAConnection.java @@ -60,10 +60,6 @@ public LogicalConnection getConnection() throws SQLException { LogicalConnection logicalConnection = new LogicalConnection(this, this.connection); - // if (this.physicalConnectionSharingCount == 0) { - // this.xaResource.setLocalTransaction(logicalConnection); - // } - this.physicalConnectionSharingCount++; this.underlyingConCloseRequired = false; @@ -105,10 +101,6 @@ public void commitLocalTransaction() throws SQLException { throw ex; } catch (RuntimeException ex) { throw new SQLException(ex); - } finally { - if (this.underlyingConCloseRequired) { - this.releaseConnection(); - } } } @@ -119,10 +111,6 @@ public void rollbackLocalTransaction() throws SQLException { throw ex; } catch (RuntimeException ex) { throw new SQLException(ex); - } finally { - if (this.underlyingConCloseRequired) { - this.releaseConnection(); - } } } @@ -135,7 +123,10 @@ public void closeQuietly() { } public void close() throws SQLException { - this.underlyingConCloseRequired = true; + if (this.underlyingConCloseRequired == false) { + logger.warn("Illegal state: there is at least one connection that is not closed!"); + } + this.releaseConnection(); } diff --git a/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXAResource.java b/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXAResource.java index 3f56dda..aba9210 100644 --- a/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXAResource.java +++ b/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXAResource.java @@ -210,7 +210,7 @@ public synchronized void commit(Xid xid, boolean onePhase) throws XAException { xae.initCause(ex); throw xae; } finally { - this.resetXAResource(); + this.releasePhysicalConnection(); } } @@ -232,11 +232,11 @@ public synchronized void rollback(Xid xid) throws XAException { xae.initCause(ex); throw xae; } finally { - this.resetXAResource(); + this.releasePhysicalConnection(); } } - private void resetXAResource() { + private void releasePhysicalConnection() { Connection connection = this.managedConnection.getPhysicalConnection(); try { connection.setAutoCommit(originalAutoCommit);