[#4277] Fixed ConnectionProvider regression on exceptions

This commit is contained in:
lukaseder 2018-04-05 21:46:44 +03:00
parent e8f63e37f4
commit 0fb8c29b1a
2 changed files with 9 additions and 8 deletions

View File

@ -101,7 +101,7 @@ class DefaultExecuteContext implements ExecuteContext {
private final int[] batchRows;
// Transient attributes (created afresh per execution)
private transient ConnectionProvider connectionProvider;
transient ConnectionProvider connectionProvider;
private transient Connection connection;
private transient SettingsEnabledConnection wrappedConnection;
private transient PreparedStatement statement;
@ -763,8 +763,8 @@ class DefaultExecuteContext implements ExecuteContext {
public final Connection acquire() {
// [#4277] Connections are acquired lazily in parent ExecuteContext. A child ExecuteContext
// may well need a Connection earlier than the parent, in case of which acquisition is
// forced in the parent as well.
// may well need a Connection earlier than the parent, in case of which acquisition is
// forced in the parent as well.
if (connection == null)
DefaultExecuteContext.this.connection();

View File

@ -2332,9 +2332,8 @@ final class Tools {
ctx.resultSet(null);
PreparedStatement statement = ctx.statement();
if (statement != null) {
if (statement != null)
consumeWarnings(ctx, listener);
}
// [#385] Close statements only if not requested to keep open
if (!keepStatement) {
@ -2348,9 +2347,11 @@ final class Tools {
else {
Connection connection = localConnection();
if (connection != null) {
ctx.configuration().connectionProvider().release(connection);
}
// [#4277] We must release the connection on the ExecuteContext's
// ConnectionProvider, as the ctx.configuration().connectionProvider()
// is replaced by a ExecuteContextConnectionProvider instance.
if (connection != null && ((DefaultExecuteContext) ctx).connectionProvider != null)
((DefaultExecuteContext) ctx).connectionProvider.release(connection);
}
}