@@ -770,7 +770,13 @@ void testShouldGetLastSessionId() throws Exception {
770770 long deadline = System .currentTimeMillis () + 10_000 ;
771771 while (System .currentTimeMillis () < deadline ) {
772772 long remaining = Math .max (1 , deadline - System .currentTimeMillis ());
773- lastId = client .getLastSessionId ().get (remaining , TimeUnit .MILLISECONDS );
773+ long iterationTimeout = Math .min (remaining , 500 );
774+ try {
775+ lastId = client .getLastSessionId ().get (iterationTimeout , TimeUnit .MILLISECONDS );
776+ } catch (java .util .concurrent .TimeoutException ignored ) {
777+ // RPC call took longer than the per-iteration cap; retry
778+ continue ;
779+ }
774780 if (sessionId .equals (lastId )) {
775781 break ;
776782 }
@@ -863,7 +869,13 @@ void testShouldGetSessionMetadataById() throws Exception {
863869 long deadline = System .currentTimeMillis () + 10_000 ;
864870 while (System .currentTimeMillis () < deadline ) {
865871 long remaining = Math .max (1 , deadline - System .currentTimeMillis ());
866- metadata = client .getSessionMetadata (sessionId ).get (remaining , TimeUnit .MILLISECONDS );
872+ long iterationTimeout = Math .min (remaining , 500 );
873+ try {
874+ metadata = client .getSessionMetadata (sessionId ).get (iterationTimeout , TimeUnit .MILLISECONDS );
875+ } catch (java .util .concurrent .TimeoutException ignored ) {
876+ // RPC call took longer than the per-iteration cap; retry
877+ continue ;
878+ }
867879 if (metadata != null ) {
868880 break ;
869881 }
0 commit comments