-
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
Improve JAXB Exception handling #39503
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
I'm not sure should I discuss the proposed fix here or in the issue. But here's what I commented in the issue earlier: Based on my tests in the Draft PR I noticed that the resteasy-reactive-jaxb and resteasy-jaxb behave differently. The reactive implementation returns 500 when an invalid xml is sent and the other one returns 400. My suggestion is that resteasy-reactive-jaxb would be modified to work like resteasy-reactive-jackson works when invalid json is sent -> WebApplicationException resulting in http 400. |
d332579
to
0a777ca
Compare
be40ee8
to
98c138c
Compare
Status for workflow
|
Well I went ahead and implemented the exception handling in a similar way that it is done in jackson as it was not a big task and I changed the status to ready for review. |
c67946c
to
bf7fa97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pull request.
I agree that the changes make sense and thank you for having a look into it and providing a pull request.
One minor gripe though: I would prefer if the test could be moved to https://github.com/quarkusio/quarkus/tree/main/extensions/resteasy-reactive/rest-jaxb/deployment/src/test/java/io/quarkus/resteasy/reactive/jaxb/deployment/test instead.
Adding an IT module means adding several minutes to the native build and I'm not sure it's worth it in this case.
A small test in the deployment module should be easier to add (you will have to adapt your test a bit though, have a look at the other tests that are already in the module).
Thanks!
3703e09
to
0729130
Compare
@gsmet ok, yeah the deployment/runtime division confused me first and I didn't notice the module had tests also there. But I removed the integration tests and added a test for the invalid xml in the module tests 👍 |
0729130
to
eae4810
Compare
If UnmarshalException is thrown (which happens for example when the xml is invalid) then a WebApplicationException is thrown with status code 400 Bad Request. This is also how resteasy-reactive-jackson handles invalid JSON.
eae4810
to
744ccfb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks.
Let's get CI to run and merge it once it is green.
Status for workflow
|
Merged! Thanks for your contribution! |
I tested the issue with resteasy-reactive-jaxb and confirmed that the response is Internal Server Error (500) when posting an invalid xml body.
I tried to reproduce the issue in the existing
jaxb
integration test, but that one returns Bad Request (400). I added tests for confirming this.I had to create a new integration test module
resteasy-reactive-jaxb
to be able to reproduce the issue with the reactive implementation. That test has been implemented to expect Bad Request (400) so at the moment the test is failing until the exception handling is fixed.