Skip to content

Commit 71f56da

Browse files
authored
chore: propagate RuntimeException from DelayedReadContext (#3150)
Propagate the underlying cause of the ExecutionException as a RuntimeException directly, if this is already a RuntimeException. This keeps the behavior of multiplexed sessions and regular sessions equal, regardless whether the Delayed... route is taken for multiplexed sessions, or the direct route is used. Fixes #3132
1 parent a165cd7 commit 71f56da

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/DelayedReadContext.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ T getReadContext() {
4444
try {
4545
return this.readContextFuture.get();
4646
} catch (ExecutionException executionException) {
47+
// Propagate the underlying exception as a RuntimeException (SpannerException is also a
48+
// RuntimeException).
49+
if (executionException.getCause() instanceof RuntimeException) {
50+
throw (RuntimeException) executionException.getCause();
51+
}
4752
throw SpannerExceptionFactory.asSpannerException(executionException.getCause());
4853
} catch (InterruptedException interruptedException) {
4954
throw SpannerExceptionFactory.propagateInterrupt(interruptedException);

0 commit comments

Comments
 (0)