@@ -60,17 +60,51 @@ public void clearRequests() {
6060 @ Test 
6161 public  void  testAsyncRunner_doesNotReturnCommitTimestampBeforeCommit () {
6262 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+  }
6683 }
6784
6885 @ Test 
6986 public  void  testAsyncRunner_doesNotReturnCommitResponseBeforeCommit () {
7087 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+  }
74108 }
75109
76110 @ Test 
@@ -558,7 +592,9 @@ public void closeTransactionBeforeEndOfAsyncQuery() throws Exception {
558592 // Wait until at least one row has been fetched. At that moment there should be one session 
559593 // checked out. 
560594 dataReceived .await ();
561-  assertThat (clientImpl .pool .getNumberOfSessionsInUse ()).isEqualTo (1 );
595+  if  (!isMultiplexedSessionsEnabledForRW ()) {
596+  assertThat (clientImpl .pool .getNumberOfSessionsInUse ()).isEqualTo (1 );
597+  }
562598 assertThat (res .isDone ()).isFalse ();
563599 dataChecked .countDown ();
564600 // Get the data from the transaction. 
0 commit comments