Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes three little problems that involve responses that arrive before the corresponding request is fully sent.
Fix 1:
HttpRequestOperation has two callback handlers on the same channel future that both trigger an observable error. Omitting a second
onError
violates Rx.Java protocol. Also it is pointless because Rx suppresses the 2ndonError
event.Impact: Confusing log messages.
Fix: collapse the two callbacks into one.
Fix 2:
"Connection: close" header was not included in some of the error responses.
Impact: The remote peer may start sending the next request on a channel that was about to be closed, resulting in a wasted request.
Fix: Add missing "Connection: close" header to the affected error responses.
Fix 3:
HttpRequestOperation.RequestBodyChunkSubscriber
was setting the request bodycompleted
flag too soon. ThereforeisOngoingRequest
test inexecute
was prematurely returning false. This could allow the connection to be handed over to the next request before the previous is fully sent, resulting in Netty HTTP codec getting out-of-sync.Impact: A failure to proxy a request to origins. Happens very rarely under heavy load. This issue may show up in load tests.
Fix: Wait until Netty has acknowledged the request EMPTY_LAST_CONTENT before setting completed flag to true.