-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
ContainerResponseContext has null default MediaType when using RESTEasy reactive #34839
Comments
I am pretty sure there is no TCK test for this so the behavior is pretty much unspecified. I am inclined to close this as |
Thahnks for answering! I can check for nullity in the filter, but I would still need to guess what the default value will be. It could lead to duplication, in the ContainerResponseFilter, of the logic quarkus-resteasy-reactive already uses for the smart defaults. I am not even sure how it is doable from within the ContainerResponseFilter since the return type of the endpoint method are used. Anyway, for my real world use case, I can treat in the same way a null value resulting a contentType text/plain, text/html, application/json. I'm more worried about binary content... PS: you may find worth a mention in the "Migrating to RESTEasy Reactive" guide. |
I am pretty sure you could handle your use case with a |
To be fair, only partially I'm afraid. The |
You can always add a |
Thanks for the reminder! I gave a try to the WriterInterceptor, and unfortunately the MediaType is PS: I couldn't find the HTTP status code |
I do find it weird that |
I was feeling so because it's not set explicitly. But I admit (and faced it), it's not practical at all. |
We should probably take a closer look at this |
Hi team, I'm having the same problem. Is there any chance this can be fixed? Or what would be an appropriate solution? Of all the frameworks I've used, I've always used ContainerResponseFilter because it facilitates the logic for obtaining the HTTP/REST context. Is there any reason why if the Controller defines the MediaType, the ContainerResponseFilter cannot access it? Thanks |
The one from the response can be null if we return a partial response but the type is defined by @produces. We need to consider the one from the context. Fixes quarkusio#34839
From what I can see, there are two different issues, one is a bug, the other I'm not entirely sure. ContainerResponseFilterIn the case of a method returning a My personal opinion is that we should probably install a handler in this case - even if it does less things than the current At least when the content type is static, it would make sense to inject it early IMO. But this decision will require more knowledge of Quarkus REST than I currently have. WriterInterceptorThis one is a different beast, it's executed late and the content type is actually injected in the Which is what #44166 tries to fix. |
My opinion is that |
The one from the response can be null if we return a partial response but the type is defined by @produces. We need to consider the one from the context. Fixes quarkusio#34839
Even when we use Response, it's interesting to push the default content type to the context as it might get used by ContainerResponseFilters. If the Response actually overrides it, it's all taken care of. Fixes quarkusio#34839
See the discussion here: #44166 (comment) . It seems that when using So we can fix the |
The one from the response can be null if we return a partial response but the type is defined by @produces. We need to consider the one from the context. Fixes quarkusio#34839
Even when we use Response, it's interesting to push the default content type to the context as it might get used by ContainerResponseFilters. If the Response actually overrides it, it's all taken care of. Fixes quarkusio#34839
Even when we use Response, it's interesting to push the default content type to the context as it might get used by ContainerResponseFilters. If the Response actually overrides it, it's all taken care of. Fixes quarkusio#34839
AFAICS, it was just an ugly bug in my code, things should be fine provided full CI is happy. |
Even when we use Response, it's interesting to push the default content type to the context as it might get used by ContainerResponseFilters. If the Response actually overrides it, it's all taken care of. Fixes quarkusio#34839
Describe the bug
Hello,
I noticed a difference between RESTEasy reactive and RESTEasy classic when using ContainerResponseFilter.
A simple endpoint returning a
Response
and that does explicitly its type will result a in anull
MediaType
in theContainerResponseContext
of aContainerResponseFilter
.Notes:
MediaType
set correctly to the default application/json when using RESTEasy classicConsidering a simple endpoint:
The following filter will throw its exception in reactive mode, but not in classic.
Expected behavior
It would help is the MediaType was available to the ContainerResponseFilter.
Actual behavior
Unfortunately, the MediaType is null.
A workaround is to force on the response:
It is however a bit tedious to add to all the Response, and defeats the purpose of a default MediaType.
How to Reproduce?
The following project is a reproducer https://github.com/gnieser/quarkus-mediatype
Output of
uname -a
orver
Windows 10
Output of
java -version
mandrel-java17-22.3.1.0-Final
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.16.8.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)OpenJDK Runtime Environment Temurin-17.0.6+10
Additional information
No response
The text was updated successfully, but these errors were encountered: