You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (JIRA)" <ji...@apache.org> on 2015/11/19 22:56:11 UTC

[jira] [Commented] (CXF-6684) A Warning is logged on every JAX-RS call

    [ https://issues.apache.org/jira/browse/CXF-6684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15014462#comment-15014462 ] 

Sergey Beryozkin commented on CXF-6684:
---------------------------------------

Unfortunately it is won't fix. In CXF 3.0.x this line is hit:

https://github.com/apache/cxf/blob/cxf-3.0.6/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java#L69.

But this check is not in CXF 2.7.x. Perhaps it was the uncompleted backmerge. The actual warning is important to avoid the problems associated with multiple competing and equivalent candidates. 

However, note that OperationResourceInfoComparator checks if a custom ResourceComparator is available.
So what you can do is to create a custom ResourceComparator which will simply return a non-0 value - which would make OperationResourceInfoComparator exit; then register this ResourceComparator as jaxrs:provider.
This is a bit unfortunate but this workaround is quite simple.

Perhaps a better option is to block the logging for OperationResourceInfoComparator at the log configuration level, this should be possible, right ?

I'm not sure if 2.7.19 will ever be made - but if it will then the fix will be made. But as I said above I think you have a couple of workarounds for 2.7.x

> A Warning is logged on every JAX-RS call
> ----------------------------------------
>
>                 Key: CXF-6684
>                 URL: https://issues.apache.org/jira/browse/CXF-6684
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.7.17
>            Reporter: Luz
>
> A Warning is logged on every JAX-RS call: " Both Object#method and Object#method are equal candidates for handling the current request which can lead to unpredictable results". This occurs even with no configuration errors (only one service with one method).
> This bug seems to be introduced by commit d58606e554418899e905cd2f3bc7e8c465eff451.
> org.apache.cxf.jaxrs.utils.JAXRSUtils#findTargetMethod uses a java.util.TreeMap with org.apache.cxf.jaxrs.model.OperationResourceInfoComparator. But java.util.TreeMap.put(K, V) calls compare(key, key) internally.
> {code:title=Test.java}
>     @Test
>     public void testWarning() throws Exception
>     {
>         Message m = new MessageImpl();
>         Exchange e = new ExchangeImpl();
>         e.setInMessage(m);
>         e.put(Endpoint.class, Mockito.mock(Endpoint.class));
>         OperationResourceInfo k = new OperationResourceInfo(getClass().getMethod("toString"),
>                 new ClassResourceInfo(getClass()));
>         k.setURITemplate(new URITemplate("template"));
>         new TreeMap<>(new OperationResourceInfoComparator(m, "GET")).put(k, new Object());
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)