eclipse-ee4j / eclipse-ee4j/jersey
ExceptionMapper not catching WebApplicationException with entity
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
I'm on Jersey 2.26
I have my own exception class that extends javax.ws.rs.WebApplicationException. It seems that when this custom exception sets an entity in the javax.ws.rs.core.Response, an ExceptionMapper cannot be used.
If I null out the entity, my ExceptionMapper behaves as expected. I had my ExceptionMapper catching Throwable/RuntimeException, so it took a day of googling to determine why this was happening.
If this is the intended result, may I suggest that the ExceptionMapper interface be documented with this gotcha.
Related issues.
https://stackoverflow.com/questions/33732408/exceptionmapper-not-working-as-expected
https://stackoverflow.com/questions/29414041/exceptionmapper-for-webapplicationexceptions-thrown-with-entity
Contributor guide
Research direction
Start by reproducing the Jersey 2.26 case with a custom javax.ws.rs.WebApplicationException containing a Response entity and an ExceptionMapper for Throwable or RuntimeException. Compare it with the same exception when the entity is null; done means the behavior is corrected or the ExceptionMapper interface documents this behavior clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100