-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
observer.onCompleted(); | ||
if (!streamingResponse) { | ||
if (unaryMessage != null) { | ||
observer.onNext(unaryMessage); |
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.
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();
}
This reverts commit fe46eda
fixes: #5968