Skip to content

stub: ignore unary response msg if status is not OK #6288

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

Merged
merged 11 commits into from
Oct 17, 2019

Conversation

ran-su
Copy link
Member

@ran-su ran-su commented Oct 16, 2019

fixes: #5968

@ran-su ran-su requested a review from ejona86 October 16, 2019 20:35
observer.onCompleted();
if (!streamingResponse) {
if (unaryMessage != null) {
observer.onNext(unaryMessage);
Copy link
Member

Choose a reason for hiding this comment

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

I only just noticed, because it is a bit subtle, but we now need to handle exceptions from onNext().

Previously if onNext() threw an exception, onMessage() would propagate the exception which would cancel the call and so onClose() would be called, which would call onError().

And the code will need a bit of an ugly dance. Maybe something like:

boolean noException = false;
try {
  observer.onNext(unaryMessage);
  noException = true;
} catch (Throwable t) {
  observer.onError(t);
}
if (noException) {
  observer.onCompleted();
}

@ran-su ran-su merged commit fe46eda into grpc:master Oct 17, 2019
@ran-su ran-su deleted the ignore_msg_when_not_ok branch October 17, 2019 21:49
ran-su added a commit to ran-su/grpc-java that referenced this pull request Oct 28, 2019
ran-su added a commit that referenced this pull request Oct 28, 2019
ran-su added a commit to ran-su/grpc-java that referenced this pull request Oct 29, 2019
ran-su added a commit that referenced this pull request Oct 29, 2019
voidzcy pushed a commit to voidzcy/grpc-java that referenced this pull request Oct 31, 2019
voidzcy pushed a commit to voidzcy/grpc-java that referenced this pull request Nov 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

async client stub: need to ignore unary response msg if status is not OK
2 participants