Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public void commit() {
} catch (SpannerException e2) {
txnState = TransactionState.COMMIT_FAILED;
throw e2;
} finally {
// At this point, if the TransactionState is not ABORTED, then the transaction has reached an
// end state.
// We can safely call close() to release resources.
if (getState() != TransactionState.ABORTED) {
close();
}
}
}

Expand All @@ -92,6 +99,9 @@ public void rollback() {
txn.rollback();
} finally {
txnState = TransactionState.ROLLED_BACK;
// At this point, the TransactionState is ROLLED_BACK which is an end state.
// We can safely call close() to release resources.
close();
}
}

Expand Down
Loading