Skip to content

Commit 4c57a82

Browse files
committed
chore(spanner): update interceptor
1 parent d547920 commit 4c57a82

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ITAbstractSpannerTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.cloud.spanner.GceTestEnvConfig;
2323
import com.google.cloud.spanner.IntegrationTestEnv;
2424
import com.google.cloud.spanner.ResultSet;
25+
import com.google.cloud.spanner.Spanner;
2526
import com.google.cloud.spanner.SpannerExceptionFactory;
2627
import com.google.cloud.spanner.SpannerOptions;
2728
import com.google.cloud.spanner.Statement;
@@ -146,6 +147,9 @@ public void intercept(
146147
if (usingMultiplexedsession) {
147148
Field stateField = cls.getDeclaredField("txnState");
148149
stateField.setAccessible(true);
150+
if (tx.getState() == null) {
151+
return;
152+
}
149153
tx.rollback();
150154
stateField.set(tx, TransactionState.ABORTED);
151155
} else {
@@ -368,4 +372,11 @@ protected boolean indexExists(Connection connection, String table, String index)
368372
}
369373
return false;
370374
}
375+
376+
protected boolean isMultiplexedSessionsEnabledForRW(Spanner spanner) {
377+
if (spanner.getOptions() == null || spanner.getOptions().getSessionPoolOptions() == null) {
378+
return false;
379+
}
380+
return spanner.getOptions().getSessionPoolOptions().getUseMultiplexedSessionForRW();
381+
}
371382
}

0 commit comments

Comments
 (0)