-
Notifications
You must be signed in to change notification settings - Fork 182
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
HTTP StreamingService to BlockingStreaming backpressure and error propagation fixes #1328
Conversation
…pagation fixes Motivation: StreamingHttpServiceToBlockingStreamingHttpService (used by HttpJerseyRouterBuilder.buildBlockingStreaming) doesn't apply any backpressure and also may not propagate error status correctly in the event the StreamingHttpResponse fails. Modifications: - PayloadPump uses the new PayloadWriter.close(Throwable) method to propagate status in the event the StreamingHttpResponse fails. - PayloadPump requests in chunks of 64 by default to apply backpresusre. That way if the blocking PayloadWriter APIs block, the source providing data will be limited to 64 chunks at most. Result: HttpApiConversions.toBlockingStreamingHttpService(StreamingHttpService) applies backpressure and propagates error status to the PayloadWriter.
this.cancel(); | ||
payloadWriter.write((Buffer) bufferOrTrailers); | ||
} catch (IOException e) { | ||
throwException(e); |
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.
Doesn't this need onError
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.
If onNext
throws the async source is responsible for catching the exception and propagating an error back downstream. Throwing the exception also effectively cancels the subscription and lets the upstream source cleanup.
We generally don't throw from terminal methods (e.g. onComplete()
, onError(Throwable)
) because the upstream source isn't allowed to invoke terminal methods more than once, so we must handle the error locally.
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.
LGTM after outstandingDemand
is improved:
...rc/main/java/io/servicetalk/http/api/StreamingHttpServiceToBlockingStreamingHttpService.java
Outdated
Show resolved
Hide resolved
build failure attributed to #999 |
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.
🚀
…isherAsBlockingIterable
build failure attributed to #1323 |
build failure attributed to #1192 |
Motivation:
StreamingHttpServiceToBlockingStreamingHttpService (used by
HttpJerseyRouterBuilder.buildBlockingStreaming) doesn't apply any
backpressure and also may not propagate error status correctly in the
event the StreamingHttpResponse fails.
Modifications:
propagate status in the event the StreamingHttpResponse fails.
That way if the blocking PayloadWriter APIs block, the source
providing data will be limited to 64 chunks at most.
Result:
HttpApiConversions.toBlockingStreamingHttpService(StreamingHttpService)
applies backpressure and propagates error status to the PayloadWriter.