Skip to content

Commit

Permalink
apache#1238 Release connection when create a new transaction.
Browse files Browse the repository at this point in the history
  • Loading branch information
cherrylzhao authored and maxiaoguang64 committed Nov 25, 2018
1 parent f57f668 commit a4d92b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ public void close() throws SQLException {
exceptions.addAll(closeStatements());
exceptions.addAll(closeResultSets());
if (ConnectionStatus.TERMINATED == status) {
exceptions.addAll(closeConnections());
cachedConnections.clear();
methodInvocations.clear();
exceptions.addAll(releaseConnections());
}
throwSQLExceptionIfNecessary(exceptions);
}
Expand Down Expand Up @@ -218,7 +216,7 @@ private Collection<SQLException> closeStatements() {
return result;
}

private Collection<SQLException> closeConnections() {
Collection<SQLException> releaseConnections() {
Collection<SQLException> result = new LinkedList<>();
for (Connection each : cachedConnections.values()) {
try {
Expand All @@ -227,6 +225,8 @@ private Collection<SQLException> closeConnections() {
result.add(ex);
}
}
cachedConnections.clear();
methodInvocations.clear();
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void doInTransaction(final TransactionOperationType operationType) throws
}
if (TransactionOperationType.BEGIN == operationType && ConnectionStatus.TRANSACTION != connection.getStatus()) {
connection.setStatus(ConnectionStatus.TRANSACTION);
connection.getCachedConnections().clear();
connection.releaseConnections();
}
if (TransactionType.LOCAL == transactionType) {
doLocalTransaction(operationType);
Expand Down

0 comments on commit a4d92b5

Please sign in to comment.