Improve error handling for Jersey's Exception that caused by client #1982
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.
If sending a POST request with a
Content-Type
header that is notapplication/x-www-form-urlencoded
and using@FormParam
in resource method, anIllegalStateException
will be thrown by Jersey and logged at ERROR level byLoggingExceptionMapper
. Also, this is the same behavior as https://java.net/jira/browse/JERSEY-2636.This indicates that users can easily output ERROR level logs in server side. Therefore, I would like to prevent this.
Steps to reproduce
@POST
and@FormParam
.Note:
@Consumes
is optional because ignoring.Content-Type
header, the 500 Internal Server Error is returned and logged at ERROR level.Impact
Probably, this change does not affected to users using the past version, because If bound an
ExceptionMapper<IllegalStateException>
atApplication#run(Configuration, Environment)
, this mappers register in the HK2 container before Dropwizard's ExceptionMapper(s) that is bound by theExceptionMapperBinder
.Please refer to the following references for details.
Reference 1: HK2 API documentation
Reference 2: org.glassfish.jersey.internal.ExceptionMapperFactory#find(Class, T)