Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JacksonFeature ExceptionMappers leaks implementation details #4200

Closed
feinstein opened this issue Jul 9, 2019 · 1 comment
Closed

JacksonFeature ExceptionMappers leaks implementation details #4200

feinstein opened this issue Jul 9, 2019 · 1 comment
Milestone

Comments

@feinstein
Copy link

The JacksonFeature ExceptionMapper<JsonParseException> and ExceptionMapper<JsonMappingException> Exception Mappers return the full error message as the Response body and there's no way to catch it and remove it.

I have an AutoValue class that Jackson tries to convert from JSON, if there's an error in the conversion (my AutoValue class doesn't accepts empty strings for its name field), I get a 400 Response with the text:

Cannot construct instance of `com.example.vo.AutoValue_User$Builder`, problem: Last name is null or empty.
at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 14, column: 1]

I tried to use an ExceptionMapper<Throwable> to catch all exceptions, log them, and return an empty Response, but it didn't work. I also tried to make my own version of the ExceptionMapper<JsonParseException> and ExceptionMapper<JsonMappingException> as it was suggested to me, but this didn't work either (worked on Tomcat, but not on other servlet containers).

Is it there a way to remove this body message?
Could you guys remove this or make it a separate module so only those interested would include it, and the rest of us could just catch those exceptions in our own Exception Mappers?

@jansupol
Copy link
Contributor

Fixed by #4225

@jansupol jansupol added this to the 2.29.1 milestone Aug 29, 2019
This was referenced Oct 21, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants