-
Notifications
You must be signed in to change notification settings - Fork 2.8k
HeaderHelper.getMediaType throws ClassCastException when Content-Type header is stored as a List #47507
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
Comments
Any chance you could prepare a small Maven reproducer? It looks legit but it's the kind of thing we can struggle to reproduce. Thanks! |
Somehow, something is wrapping what should be a single content type into a List and this is what you see. That being said, there's something odd because I think we really need a small reproducer to be able to check what's going on. |
Apologies in advance my reproducers are never the most simple, but I think this one is easy to run. Decompress the folder and run the
Once the servers are up, takes couple of seconds hit the endpoint using the following:
Expect an exception like the one mentioned in the issue above. |
OK, so you can workaround it by being a bit more careful when copying the headers and iterate on them if a list is returned but I kinda agree we should do better on our side. Working on a PR. |
The reproducer has that header iteration, but the problem happens before. That iteration was just an experiment I was trying out related to yet another issue. |
The JAX-RS API is very loose and allows adding Object and in some cases we actually add a List to the headers and we need to take this into account. While I'm usually not for handling things this way, the API is not enforcing things properly so I think we really need to handle this ourself. Fixes quarkusio#47507
So from what I can see, if I drop the header transformation from your reproducer, things are working fine, even without my patch. So my PR is fixing the issue in the reproducer but I'm not sure it will fix the issue you have in your app, if you're under the impression it's not these lines failing. It might but I'm not sure. Also there's something that is problematic in your issue description:
I think you should try to understand what's going on there with your dependency tree. On the positive side, I created a PR here: #47546 . I would be interested in your feedback. Ideally if could build my PR and test things with your app, that would give us an indication as to if the issue is fixed for you. https://github.com/quarkusio/quarkus/blob/main/CONTRIBUTING.md#checking-an-issue-is-fixed-in-main might help (except you have to build my PR code instead as long as it's not merged). |
That's correct, and to clear things out, removing the handling of the headers stops the exception to be thrown. What I meant is the code triggers the exception at a lower level.
Again you are right here, I've cleanup the dependencies and without the headers handling I don't get the original issue (not disclosed) and the exception.
I think if there was a need to handle the headers the issue would still be there, so I believe your PR still valid.
Thanks for looking into this, it's really appreciated. |
Describe the bug
Using the resteasy-client to fetch a binary file "svg" i'm getting a ClassCastException.
Request:
The exception:
Expected behavior
Return the excepted content media type.
Actual behavior
Throws an exception.
How to Reproduce?
A client like this:
Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
No response
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: