[
https://issues.apache.org/jira/browse/CXF-5360?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13807899#comment-13807899
]
Sergey Beryozkin commented on CXF-5360:
---------------------------------------
Hi Ivan, thanks for your thoughts and effort.
Let me comment: this is implemented in CXF 3.0.0 SNAPSHOT as a new JAXRS 2.0
feature, it was too sensitive to do it in CXF 2.7.x.
It is not even a bug to be honest, JAX-RS 1.1 makes the selection random in
such cases. CXF 2.7.x does implements most of JAX-RS 2.0 but not this new
feature.
I don't see why you can not use ResourceComparator in CXF 2.7.x. You can easily
decide which ClassResourceInfo to select from by getting a Message.REQUEST_URI
property, if it ends with "bar" (or some other values known to be supported by
Foo) then select Foo, etc. The runtime will select the Foo method itself, you
just return 0 when comparing operations. Also, as an alternative consider
avoiding having the same Path value on root resources, this slows down a bit
the selection process, is it not really asd sequential as in your code, all
matching candidates have to be pickup up from all the matching root resources
and then the best candidate have to be selected, so if you have a single root
resource to continue from then it it better, example, subresources may help
Please do that, I'm afraid that is not fixable in CXF 2.7.x.
> Resource classes are selected incorrectly
> -----------------------------------------
>
> Key: CXF-5360
> URL: https://issues.apache.org/jira/browse/CXF-5360
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 2.7.7
> Reporter: Ivan Bondarenko
> Priority: Blocker
>
> The problem: the resource is selected incorrectly when multiple classes can
> 'visually' handle request. For example if we have two classes
> {code}@Path("/") class Foo {
> @GET @Path("bar") public String bar() { return "bar"; }
> }
> @Path("/") class Real {
> @GET @Path("hello") public String hello() { return "hello"; }
> }{code}
> and their instances are registered in this order (e.g. in
> jaxrs:serviceBeans), when I GET the "/hello" path, the Foo will be selected,
> while it is not even able to handle this request.
> The starting point to investigate the problem is
> org.apache.cxf.jaxrs.utils.JAXRSUtils.selectResourceClass(List<ClassResourceInfo>,
> String, MultivaluedMap<String, String>, Message), where 'candidateList'
> variable is filled incorrectly. Unfortunately I'm not so familiar with CXF
> code to provide a patch, but resource class must be selected basing on full
> class description (all methods and annotations must be taken into account).
> Why this is a problem: except obvious reason (unexpected behavior), this bug
> disallows to make REST service modular. For example we may want to provide
> different feature sets for different servers. Right now it is not possible to
> implement.
--
This message was sent by Atlassian JIRA
(v6.1#6144)