-
Notifications
You must be signed in to change notification settings - Fork 177
Fixed GrpcRetryer#retryWithResultAsync implementation #477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0b6787e
to
f5b0ade
Compare
}); | ||
fail("unreachable"); | ||
} catch (Exception e) { | ||
// I'm not sure it's a good idea to replace interrupted exception with CancellationException, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note this comment. I don't think it's a good practice to shadow InterruptedExcption like this even while we save the interrupted flag in GrpcRetryer. Also, it's inconsistent with the Async version of this method.
return new ValueExceptionPair<>(CompletableFuture.completedFuture(r), null); | ||
} | ||
if (e instanceof CompletionException) { | ||
e = e.getCause(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave a comment explaining why we do what we do?
Also it's possible for CompletionException to be constructed without cause, should we still do this trick in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave a comment explaining why we do what we do?
I added the comment, also there are tests for both wrapped and unwrapped exceptions added in this PR.
Also it's possible for CompletionException to be constructed without cause, should we still do this trick in that case?
It's kinda an illegal state. CompletionException is intended to be a wrapper over another exception. But it's technically possible and it will work correctly: The next if
check will be true and we will return without retrying because GrpcRetrier retries only StatusRuntimeException.
What was changed:
GrpcRetryer#retryWithResultAsync
implementation was fixed to correctly unwrapCompletionException
Tests provided for
GrpcRetryer
.The unused
Retryer
class is deleted.Closes issue:
Issue #476
How was this tested:
Basic unit tests for GrpcRetryer were added