Skip to content

Conversation

Spikhalskiy
Copy link
Contributor

@Spikhalskiy Spikhalskiy commented May 9, 2021

What was changed:

GrpcRetryer#retryWithResultAsync implementation was fixed to correctly unwrap CompletionException
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

@Spikhalskiy Spikhalskiy force-pushed the issue-476 branch 4 times, most recently from 0b6787e to f5b0ade Compare May 9, 2021 06:36
});
fail("unreachable");
} catch (Exception e) {
// I'm not sure it's a good idea to replace interrupted exception with CancellationException,
Copy link
Contributor Author

@Spikhalskiy Spikhalskiy May 9, 2021

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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix

Copy link
Contributor

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?

Copy link
Contributor Author

@Spikhalskiy Spikhalskiy May 10, 2021

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.

@vitarb vitarb merged commit df5f244 into temporalio:master May 11, 2021
@Spikhalskiy Spikhalskiy deleted the issue-476 branch April 15, 2022 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants