Guard inner flush in ServerCall.writeResponseBody for Jetty 12 compatibility#1508
Open
nico-mayora wants to merge 1 commit into
Open
Guard inner flush in ServerCall.writeResponseBody for Jetty 12 compatibility#1508nico-mayora wants to merge 1 commit into
nico-mayora wants to merge 1 commit into
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



The aim
Stop spurious SEVERE log entries and bogus 500 retries on every Restlet response served via the Jetty 12 connector. The wire response is already correct, only logging and the retry path misbehave.
The solution
Guard the inner
responseEntityStream.flush()inServerCall.writeResponseBodywith a try/catch that logs atFINE, mirroring the pattern already used bysendResponse()'sfinallyblock two methods up.org.eclipse.jetty.io.content.BufferedContentSinkin Jetty 12 strictly enforces theContent.Sinkcontract: once a write withlast=truehas occurred, any subsequent write or flush completes the callback withIOException("complete"). Under Jetty 9 / 11 the same flush was silently tolerated.That
IOExceptionpropagates fromwriteResponseBodyup toServerAdapter.commit, where it's caught and logged atSEVEREas "An exception occurred writing the response entity" and triggers a retry against a response whose body bytes are already on the wire.The outer flush+close in
sendResponse()'s finally block already wraps the same operation:This patch mirrors that exact treatment on the inner flush:
Reproduction
org.restlet.ext.jetty2.6.0.ServerResourcereturning a simple representation, e.g.Check-list
DO NOT REVIEW