-
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
Unexpected content-type can cause two different exceptions depending on the jax-rs resource #36798
Comments
/cc @FroMage (resteasy-reactive), @stuartwdouglas (resteasy-reactive) |
I will have a look sometime next week |
Unfortunately there is not much we can do here as this behavior is tested by the TCK |
Really, the behaviour of jax-rs changes if you switch to quarkus-resteasy-reactive instead of quarkus-resteasy. In my opinon, jax-rs should always behave the same. Also, I don't think I have ever seen resteasy throw jakarta.ws.rs.WebApplicationException server side but I might be wrong. |
That's odd... I'll have another look tomorrow to see what RESTEasy Classic is doing |
This is not only how RESTEasy Classic behaves, but also the exception that RESTEasy Reactive itself uses in other places where media type mapping fails Fixes: quarkusio#36798
Use proper exception when media type handling is incorrect
This is not only how RESTEasy Classic behaves, but also the exception that RESTEasy Reactive itself uses in other places where media type mapping fails Fixes: quarkusio#36798
This is not only how RESTEasy Classic behaves, but also the exception that RESTEasy Reactive itself uses in other places where media type mapping fails Fixes: quarkusio#36798
Describe the bug
I have been implementing a jax-rs resource in Quarkus which needs to use media type versioning. Unfortunately, Quarkus doesn't seem to be consistent wrt. which exceptions are thrown.
If somebody tries to access the jax-rs resource with an unexpected content-type, two different exceptions are thrown depending on the number of methods implemented inside the REST resource. If the resource only has a single method, the thrown exception is a jakarta.ws.rs.NotSupportedException but when the resource has more than one method an jakarta.ws.rs.WebApplicationException is thrown.
It is not really the biggest problem in the world, but my exception mappers got confused and I ended up spending quite some time debugging my application.
See my post at stackoverflow.
Expected behavior
It should throw jakarta.ws.rs.NotSupportedException in all cases.
Actual behavior
Throws jakarta.ws.rs.NotSupportedException when the jax-rs resource only contains a single method and jakarta.ws.rs.WebApplicationException if the jax-rs resource contains more than one method.
How to Reproduce?
I have added a small application to github illustrating the problem test-reactive-jaxrs. The application is created by https://code.quarkus.io/ and it only uses the extention quarkus-resteasy-reactive-jsonb (and arc). The jax-rs resource is this GreetingResource. If it contains one method then one exception is thrown, if it contains two methods another exception is thrown. The tests are executed by running the test-run.sh script.
If the none-reactive version of the extension (quarkus-resteasy-jsonb) is used, then jakarta.ws.rs.NotSupportedException is thrown in all cases.
Output of
uname -a
orver
Linux 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
openjdk version "17.0.8" 2023-07-18
Quarkus version or git rev
3.4.3 (or 3.5.0)
Build tool (ie. output of
mvnw --version
orgradlew --version
)Gradle 8.1.1
Additional information
No response
The text was updated successfully, but these errors were encountered: