Replies: 1 comment
-
The resolution to matching paths is done via https://jakarta.ee/specifications/restful-ws/3.0/jakarta-restful-ws-spec-3.0.html#mapping_requests_to_java_methods. Note this is 3.0 documentation, but it's the same as 2.1. Basically you're simply passing "http://localhost:8080/hello". That will result in
In other words, you can't really override a request URI like that. Both methods will be chosen and you shouldn't rely on which method of the two is chosen by the implementation. |
Beta Was this translation helpful? Give feedback.
-
I have a question about JAX-RS Spec and Resteasy implementation.
According to JAX-RS 2.0 annotation are inherited by the super-class or the interface. If the sub-class has own JAX-RS annotations the annotations of the super-class are ignored. The same behaviour for methods. https://download.oracle.com/otn-pub/jcp/jaxrs-2_0-fr-eval-spec/jsr339-jaxrs-2.0-final-spec.pdf
JAX-RS 2.1 spec still the same.
Now I have an example done in Quarkus 2.16 (should use Resteasy 4.7.7.Final) with two classes. Class HelloResource and Hello2Resource, Hello2Resource extends HelloResource. Both classes have Path annotation and both have a hello() method which returns a String. Strangely both Resources are available and can be used. I would have thought that according to the spec url/hello isn't available.
Example is here: https://github.com/hamburml/resteasy-inheritance
What I also dont understand - if I change the Path of Hello2Resource to /hello (which is the same as HelloResource) I would have thought that HelloResource is hidden, because Hello2Resource extends from HelloResource and has jax-rs annotations.
Can anyone shed some light? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions