File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
google-cloud-spanner/src/main/java/com/google/cloud/spanner Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ public TransactionContext begin() {
4949 return getTransactionManager ().begin ();
5050 }
5151
52+ @ Override
53+ public TransactionContext begin (AbortedException exception ) {
54+ return getTransactionManager ().begin (exception );
55+ }
56+
5257 @ Override
5358 public void commit () {
5459 getTransactionManager ().commit ();
Original file line number Diff line number Diff line change @@ -61,6 +61,8 @@ enum TransactionState {
6161 */
6262 TransactionContext begin ();
6363
64+ TransactionContext begin (AbortedException exception );
65+
6466 /**
6567 * Commits the currently active transaction. If the transaction was already aborted, then this
6668 * would throw an {@link AbortedException}.
Original file line number Diff line number Diff line change @@ -53,8 +53,19 @@ public void setSpan(ISpan span) {
5353 @ Override
5454 public TransactionContext begin () {
5555 Preconditions .checkState (txn == null , "begin can only be called once" );
56+ return begin (ByteString .EMPTY );
57+ }
58+
59+ @ Override
60+ public TransactionContext begin (AbortedException exception ) {
61+ Preconditions .checkState (txn == null , "begin can only be called once" );
62+ ByteString previousAbortedTransactionID = exception .getTransactionID () != null ? exception .getTransactionID () : ByteString .EMPTY ;
63+ return begin (previousAbortedTransactionID );
64+ }
65+
66+ TransactionContext begin (ByteString previousTransactionId ) {
5667 try (IScope s = tracer .withSpan (span )) {
57- txn = session .newTransaction (options , /* previousTransactionId = */ ByteString . EMPTY );
68+ txn = session .newTransaction (options , /* previousTransactionId = */ previousTransactionId );
5869 session .setActive (this );
5970 txnState = TransactionState .STARTED ;
6071 return txn ;
You can’t perform that action at this time.
0 commit comments