-
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
CompletionStage behaviour in case of WebApplicationException #4463
Comments
What is happening is
Now, it is possible to map the nested exception in Jersey, however, there may be a use case where the user would not want to decapsulate the nested exception. In that case, Jersey would not be able to help. In your case, there are two possible solutions.
|
|
The combination of |
Can #3978 also be progressed as they are different sides of the same async coin? |
I don't know either. On my side I asked the question, because I was surprised and I would have expected the behavior to be coherent with the sync exception handling (unwrap and convert to response) |
I just hit this as well and was quite surprised. Given the nature of |
@twbecker Can you be more specific about your issue? What Jersey version do you use? What is the exception you hit? Can you share a stacktrace? |
@jansupol Using Jersey 3.0.12. I didn't hit an exception in Jersey, I'm talking about how exceptions are handled by Jersey. Basically, I'd expect the following resource methods to return identical responses, but they don't: @Path("/")
public class Resource {
@GET
@Path("/sync")
public Response synchronous() {
throw new ServiceUnavailableException();
}
@GET
@Path("/async")
public CompletionStage<Response> asynchronous() {
return CompletableFuture.supplyAsync(() -> {
throw new ServiceUnavailableException();
});
}
} Specifically, the exception from the async method does not go through the |
Hello,
I'm faced with a case where I'm not sure what the behavior should be.
When throwing a WebApplicationException, jersey automatically translates the exception in its corresponding response.
While using CompletionStage, I would expect the behavior to be similar. In practice, it translates to an internal server error. The JAX-RS specification is not very clear on that particular point
Consider the following case :
I would actually expect to get an HTTP 406, instead of a 500.
Can you clarify the current behavior and the way this kind of error is supposed to be handled ?
Thanks a lot!
The text was updated successfully, but these errors were encountered: