cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Gerber (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CXF-5066) Annotation inheritance does not work if a non JAX-RS annotation is present on an implementation method
Date Wed, 12 Jun 2013 22:52:20 GMT

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

Simon Gerber commented on CXF-5066:
-----------------------------------

My sincere apologies - reviewing my test case the actual cause of my issue was mixing and
matching parameter and method annotations.

I.e.

{noformat}
@Path("example")
public interface Example {
     
    @Path("{reference}")
    ExampleResponse get(@PathParam("reference") String reference);
}

public class ExampleImpl implements Example {

    @Override
    public ExampleResponse get(@PathParam("reference") String reference) { // ... }
}
{noformat}

Eclipse's 'extract interface' refactor leaves the annotations behind on the implementation
class - and I forgot to strip the PathParam annotations. At the time I was absolutely convinced
I saw this issue on a method that only had the Path annotation - but I cannot replicate now
either.
                
> Annotation inheritance does not work if a non JAX-RS annotation is present on an implementation
method
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CXF-5066
>                 URL: https://issues.apache.org/jira/browse/CXF-5066
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.7.5
>            Reporter: Simon Gerber
>            Priority: Minor
>
> Consider an annotated interface and implementation as follows
> {noformat}
> @Path("example")
> public interface Example {
>      
>     @GET
>     ExampleResponse get();
> }
> public class ExampleImpl implements Example {
>     @Override
>     public ExampleResponse get() { // ... }
> }
> {noformat}
> The documentation states that 'most JAX-RS annotations can be inherited from the superclass
or interface'. However in the above example CXF will reject this resource as ResourceUtils.createClassResourceInfo()
fails to find any dispatcher methods. 
> The reason for this is that AnnotationUtils.doGetAnnotatedMethod() returns the concrete
class method because it has an Override annotation on it. Therefore it does not find the method
annotation.
> The workaround is to remove the Override annotation - however since many IDEs (such as
Eclipse) are configured to add this by default it could be considered a case where user expectations
will not be met. This caveat was not documented anywhere and it required debugging into the
CXF source code to isolate the issue.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message