@@ -544,6 +544,7 @@ final void updateStateFromResponse(BidiWriteObjectResponse response) {
544544 if (state == State .INITIALIZING || state == State .RETRYING ) {
545545 transitionTo (
546546 stateToReturnToAfterRetry != null ? stateToReturnToAfterRetry : State .RUNNING );
547+ stateToReturnToAfterRetry = null ;
547548 }
548549
549550 boolean signalTerminalSuccess = false ;
@@ -679,7 +680,9 @@ final void pendingRetry() {
679680 lock .lock ();
680681 try {
681682 validateCurrentStateIsOneOf (State .allNonTerminal );
682- stateToReturnToAfterRetry = state ;
683+ if (state != State .RETRYING && state != State .PENDING_RETRY ) {
684+ stateToReturnToAfterRetry = state ;
685+ }
683686 transitionTo (State .PENDING_RETRY );
684687 } finally {
685688 lock .unlock ();
@@ -887,10 +890,11 @@ void awaitState(State... anyOf) throws InterruptedException {
887890 lock .lock ();
888891 try {
889892 ImmutableSet <State > states = ImmutableSet .copyOf (anyOf );
890- while (!states .contains (this .state ) && ! stateUpdated . await ( 5 , TimeUnit . MILLISECONDS ) ) {
893+ while (!states .contains (this .state )) {
891894 if (resultFuture .isDone ()) {
892895 return ;
893896 }
897+ stateUpdated .await (5 , TimeUnit .MILLISECONDS );
894898 }
895899 } finally {
896900 lock .unlock ();
@@ -913,11 +917,11 @@ public void awaitTakeoverStateReconciliation(Runnable restart) {
913917 public void awaitAck (long writeOffset ) throws InterruptedException {
914918 lock .lock ();
915919 try {
916- while (confirmedBytes < writeOffset
917- && !confirmedBytesUpdated .await (5 , TimeUnit .MILLISECONDS )) {
920+ while (confirmedBytes < writeOffset ) {
918921 if (resultFuture .isDone ()) {
919922 return ;
920923 }
924+ confirmedBytesUpdated .await (5 , TimeUnit .MILLISECONDS );
921925 }
922926 } finally {
923927 lock .unlock ();
0 commit comments