eclipse-ee4j / eclipse-ee4j/jersey
Jersey Microprofile RestClient does not throw checked exception declared by the resource
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
We're moving from CXF to Jersey's implementation of Microprofile RestClient and we're seeing some discrepancy in management of exception.
Current jersey RestClient implementation is to always wrap a checked exception in a WebApplicationException if this checkd exception is declared by the resource.
This has two big downsides :
- It makes the actual exception that we want to use more difficult to access. We have to use some boilerplate code to unwrap it from the WebApplicationException (that always default to a status 500 in spite of the actual response status).
- We still have to declare the CheckedException in all the method using the client.
The last point is the biggest issue here because it force the code using the Jersey RestClient to declare exception in its methods signatures, even though these checked exception will never actually be thrown.
Even though this does not seem strictly specified by the MicroProfile RestClient specification, we'd really like to see a behavior that would feel more sensible (and closer to CXF), which could be :
- Throw checked exception if declared by the resource
- Throw any unchecked exception
- Throw a `WebApplicationException` wrapping a checked exception that is not declared by the resource
Contributor guide
Research direction
No implementation file or test is named in the issue. Start by locating Jersey's MicroProfile RestClient exception-handling entry point and reproduce calls with declared checked, undeclared checked, and unchecked exceptions; done means the three requested exception behaviors are implemented and covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100