-
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
MessageBodyWriter is called with genericType CompletionStage<T> when the resource method returns CompletionStage<T> #4640
Comments
I think this should be be false when |
This looks reasonable, but it changes the behaviour for message body providers. The There would be needed a configuration option to unwrap the |
That makes sense, and I assume the current behavior would have to be the default? What about Jersey 3.0 or a future version of 2.? |
Yes, for Jersey 2.x the old behaviour should be the default. We already released Jersey 3.0.0, too. |
We currently go with the following. |
Any documentation changes I can review or help with? |
This issue seems related #4463 and the root cause seems to be lack of detail in the JAX-RS spec These are the only relevant references to CompletionStage I could find and they are light on details, especially regarding exceptions. |
We will be able to change the default behaviour for Jakarta RESTful Web Services 3.1. implementation (possibly Jersey 3.1). It would be nice to mention it in the 3.x migration guide, then. Currently, the 3.x guide is under developement. |
After executing a ResourceMethod with return type
CompletionStage<T>
the MessageBodyWriter is called with an object of type T, a type of T, but a genericType ofCompletionStage<T>
.The spec is a little vague on CompletionStage, but I think the genericType should unwrap the CompletionStage and just be
T
.The current behavior is incongruous with, say, a ResourceMethod that returns Response - where MessageBodyWriter is called with the Response's entity, the type of it's entity, and the generic type of it's entity. e.g. a method that responds with
Resource.ok("test")
causesMessageBodyWriter("test", String, String)
, not("test", String, Response)
.It looks like #3672 describes the same issue but the PR tries to fix it in jackson, when I think the fix should be be made in Jersey if my understanding of the spec is correct. I found the same issue using the GsonMessageBodyProvider from immutables and it seems like a foot gun for any code using the genericType.
The text was updated successfully, but these errors were encountered: