fix: ignore errors during Connection.close() (#1877) · googleapis/java-spanner@6ab8ed2 (original) (raw)

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -298,12 +298,16 @@ public ApiFuture closeAsync() {
298 298 abortBatch();
299 299 }
300 300 if (isTransactionStarted()) {
301 -futures.add(rollbackAsync());
301 +try {
302 +futures.add(rollbackAsync());
303 + } catch (Exception exception) {
304 +// ignore and continue to close the connection.
305 + }
302 306 }
303 307 // Try to wait for the current statement to finish (if any) before we actually close the
304 308 // connection.
305 309 this.closed = true;
306 -// Add a no-op statement to the execute. Once this has been executed, we know that all
310 +// Add a no-op statement to the executor. Once this has been executed, we know that all
307 311 // preceding statements have also been executed, as the executor is single-threaded and
308 312 // executes all statements in order of submitting.
309 313 futures.add(statementExecutor.submit(() -> null));