File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
google-cloud-spanner/src/main/java/com/google/cloud/spanner Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,13 @@ public void commit() {
8080 } catch (SpannerException e2 ) {
8181 txnState = TransactionState .COMMIT_FAILED ;
8282 throw e2 ;
83+ } finally {
84+ // At this point, if the TransactionState is not ABORTED, then the transaction has reached an
85+ // end state.
86+ // We can safely call close() to release resources.
87+ if (getState () != TransactionState .ABORTED ) {
88+ close ();
89+ }
8390 }
8491 }
8592
@@ -92,6 +99,9 @@ public void rollback() {
9299 txn .rollback ();
93100 } finally {
94101 txnState = TransactionState .ROLLED_BACK ;
102+ // At this point, the TransactionState is ROLLED_BACK which is an end state.
103+ // We can safely call close() to release resources.
104+ close ();
95105 }
96106 }
97107
You can’t perform that action at this time.
0 commit comments