-
Notifications
You must be signed in to change notification settings - Fork 357
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
jersey 3.1 default exception mapper message interferes with setStatusOverSendError=true #5558
Comments
Fixed by #5612. |
Thanks @jansupol ! |
@jansupol is there a way to suppress this new behavior of adding error message to the response for unmapped exceptions?? |
@Subrhamanya What would you prefer to be the behavior for the thrown exception? |
I mean I want to go back to jetty 2.x behavior where we didn't get this message logged. Specifically this one An exception mapping did not successfully produce and processed a response. Logging the exception propagated to the default exception mapper @jansupol anything you can suggest here? Like I uplifted my code from jersey 2.x to 3.x along with spring and now when I throw runtime exception, in the response, previously I used to get the error message but after the uplift, I am getting Request failed ie jersey 2.x response:
jersey 3.x response
I expected jersey 3.x message to be same as that of jersey 2.x.. Here is how we are creating/ throwing error
|
We are currently using Jersey 2 and have
jersey.config.server.response.setStatusOverSendError
set to true so that we can post-process the response in a servlet filter when exceptions make their way out of Jersey and to a servlet filter.Here is snippet from setStatusOverSendError docs explaining the behavior we are relying on:
This is necessary because
sendError
will cause the servlet container to close the response. UsingsetStatus
by settingjersey.config.server.response.setStatusOverSendError=true
avoids this and allows post-processing the response.Jersey 3.1 introduces a default exception mapper that adds the following error message to the response for unmapped exceptions:
The fact that this message exists makes post-processing of the response when
setStatusOverSendError=true
impossible because servlet container will close the response whenContent-Length
is set and the full response entity has been written. WhilesendError
is one way that will trigger the servlet container to close the response (which is whatsetStatusOverSendError
is trying to account for), settingContent-Length
and writing this much data will also trigger the servlet container to close the response.Expected Outcome
When
jersey.config.server.response.setStatusOverSendError=true
, exceptions that make their way to servlet filter do not trigger response closure so that post-processing of the response is possible.The text was updated successfully, but these errors were encountered: