@@ -60,17 +60,51 @@ public void clearRequests() {
60
60
@ Test
61
61
public void testAsyncRunner_doesNotReturnCommitTimestampBeforeCommit () {
62
62
AsyncRunner runner = client ().runAsync ();
63
- IllegalStateException e =
64
- assertThrows (IllegalStateException .class , () -> runner .getCommitTimestamp ());
65
- assertTrue (e .getMessage ().contains ("runAsync() has not yet been called" ));
63
+ if (isMultiplexedSessionsEnabledForRW ()) {
64
+ Throwable e = assertThrows (Throwable .class , () -> runner .getCommitTimestamp ().get ());
65
+ // If the error occurs within the future, it gets wrapped in an ExecutionException.
66
+ // This happens when DelayedAsyncRunner is invoked while the multiplexed session is not yet
67
+ // created.
68
+ // If the error occurs before the future is created, it may throw an IllegalStateException
69
+ // instead.
70
+ assertTrue (e instanceof ExecutionException || e instanceof IllegalStateException );
71
+ if (e instanceof ExecutionException ) {
72
+ Throwable cause = e .getCause ();
73
+ assertTrue (cause instanceof IllegalStateException );
74
+ assertTrue (cause .getMessage ().contains ("runAsync() has not yet been called" ));
75
+ } else {
76
+ assertTrue (e .getMessage ().contains ("runAsync() has not yet been called" ));
77
+ }
78
+ } else {
79
+ IllegalStateException e =
80
+ assertThrows (IllegalStateException .class , () -> runner .getCommitTimestamp ());
81
+ assertTrue (e .getMessage ().contains ("runAsync() has not yet been called" ));
82
+ }
66
83
}
67
84
68
85
@ Test
69
86
public void testAsyncRunner_doesNotReturnCommitResponseBeforeCommit () {
70
87
AsyncRunner runner = client ().runAsync ();
71
- IllegalStateException e =
72
- assertThrows (IllegalStateException .class , () -> runner .getCommitResponse ());
73
- assertTrue (e .getMessage ().contains ("runAsync() has not yet been called" ));
88
+ if (isMultiplexedSessionsEnabledForRW ()) {
89
+ Throwable e = assertThrows (Throwable .class , () -> runner .getCommitResponse ().get ());
90
+ // If the error occurs within the future, it gets wrapped in an ExecutionException.
91
+ // This happens when DelayedAsyncRunner is invoked while the multiplexed session is not yet
92
+ // created.
93
+ // If the error occurs before the future is created, it may throw an IllegalStateException
94
+ // instead.
95
+ assertTrue (e instanceof ExecutionException || e instanceof IllegalStateException );
96
+ if (e instanceof ExecutionException ) {
97
+ Throwable cause = e .getCause ();
98
+ assertTrue (cause instanceof IllegalStateException );
99
+ assertTrue (cause .getMessage ().contains ("runAsync() has not yet been called" ));
100
+ } else {
101
+ assertTrue (e .getMessage ().contains ("runAsync() has not yet been called" ));
102
+ }
103
+ } else {
104
+ IllegalStateException e =
105
+ assertThrows (IllegalStateException .class , () -> runner .getCommitResponse ());
106
+ assertTrue (e .getMessage ().contains ("runAsync() has not yet been called" ));
107
+ }
74
108
}
75
109
76
110
@ Test
@@ -558,7 +592,9 @@ public void closeTransactionBeforeEndOfAsyncQuery() throws Exception {
558
592
// Wait until at least one row has been fetched. At that moment there should be one session
559
593
// checked out.
560
594
dataReceived .await ();
561
- assertThat (clientImpl .pool .getNumberOfSessionsInUse ()).isEqualTo (1 );
595
+ if (!isMultiplexedSessionsEnabledForRW ()) {
596
+ assertThat (clientImpl .pool .getNumberOfSessionsInUse ()).isEqualTo (1 );
597
+ }
562
598
assertThat (res .isDone ()).isFalse ();
563
599
dataChecked .countDown ();
564
600
// Get the data from the transaction.
0 commit comments