cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander Shvid (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CXF-6078) AnnotationUtils.getAnnotatedMethod for abstract classes non inherent from interface
Date Sat, 01 Nov 2014 03:44:33 GMT

     [ https://issues.apache.org/jira/browse/CXF-6078?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Alexander Shvid updated CXF-6078:
---------------------------------
    Description: 
I created the special junit test to demonstrate this bug.

Suppose we have NameService with annotated methods: 'get' and 'set'.

NameServiceImpl that implements NameService and only 'get' method.

AbstractNameServiceImpl that implements 'set' method. 
NameServiceImpl extends AbstractNameServiceImpl.

For this case AnnotationUtils.getAnnotatedMethod returns wrond annotatedMethod for 'set'.
It is actually same method as requested one, not an interface's 'set' method.

m = public javax.ws.rs.core.Response NameServiceImpl.get(java.lang.String)
a = public abstract javax.ws.rs.core.Response NameService.get(java.lang.String)
m = public javax.ws.rs.core.Response AbstractNameServiceImpl.set(java.lang.String)
a = public javax.ws.rs.core.Response AbstractNameServiceImpl.set(java.lang.String)

JDK1.7.0_51

It happens because AnnotationUtils.getAnnotatedMethod has only single argument Method, that
is only from super class AbstractNameServiceImpl and does not check hierarchy of the NameServiceImpl
itself.
AnnotationUtils.getAnnotatedMethod needs additional Class<?> serviceClass argument for
this purpose.

It actually affects ResourceUtils.createClassResourceInfo
that calls AnnotationUtils.getAnnotatedMethod to detect annotated method in the loop

    private static void evaluateResourceClass(ClassResourceInfo cri, boolean enableStatic)
{
        MethodDispatcher md = new MethodDispatcher();
        for (Method m : cri.getServiceClass().getMethods()) {
            
            Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(m);

It knows about ServiceClass, but does not use this information to walk in classes hierarchy.
For me, this bug leads to the situation that not all methods have mapping in the application.



  was:
I created the special junit test to demonstrate this bug.

Suppose we have NameService with annotated methods: 'get' and 'set'.

NameServiceImpl that implements NameService and only 'get' method.

AbstractNameServiceImpl that implements 'set' method. 
NameServiceImpl extends AbstractNameServiceImpl.

For this case AnnotationUtils.getAnnotatedMethod returns wrond annotatedMethod for 'set'.
It is actually same method as requested one, not an interface's 'set' method.

m = public javax.ws.rs.core.Response NameServiceImpl.get(java.lang.String)
a = public abstract javax.ws.rs.core.Response NameService.get(java.lang.String)
m = public javax.ws.rs.core.Response AbstractNameServiceImpl.set(java.lang.String)
a = public javax.ws.rs.core.Response AbstractNameServiceImpl.set(java.lang.String)

JDK1.7.0_51

It happens because AnnotationUtils.getAnnotatedMethod has only single argument Method, that
is only from super class AbstractNameServiceImpl and does not check hierarchy of the NameServiceImpl
itself.
AnnotationUtils.getAnnotatedMethod needs additional Class<?> serviceClass argument for
this purpose.

It actually affects ResourceUtils.createClassResourceInfo
that calls AnnotationUtils.getAnnotatedMethod to detect annotated method in the loop

    private static void evaluateResourceClass(ClassResourceInfo cri, boolean enableStatic)
{
        MethodDispatcher md = new MethodDispatcher();
        for (Method m : cri.getServiceClass().getMethods()) {
            
            Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(m);

It knows about ServiceClass, but does not use this information to walk in classes hierarchy.





> AnnotationUtils.getAnnotatedMethod for abstract classes non inherent from interface
> -----------------------------------------------------------------------------------
>
>                 Key: CXF-6078
>                 URL: https://issues.apache.org/jira/browse/CXF-6078
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.7.13
>            Reporter: Alexander Shvid
>         Attachments: AbstractNameServiceImpl.java, AnnotationUtilsTest.java, NameService.java,
NameServiceImpl.java
>
>
> I created the special junit test to demonstrate this bug.
> Suppose we have NameService with annotated methods: 'get' and 'set'.
> NameServiceImpl that implements NameService and only 'get' method.
> AbstractNameServiceImpl that implements 'set' method. 
> NameServiceImpl extends AbstractNameServiceImpl.
> For this case AnnotationUtils.getAnnotatedMethod returns wrond annotatedMethod for 'set'.
It is actually same method as requested one, not an interface's 'set' method.
> m = public javax.ws.rs.core.Response NameServiceImpl.get(java.lang.String)
> a = public abstract javax.ws.rs.core.Response NameService.get(java.lang.String)
> m = public javax.ws.rs.core.Response AbstractNameServiceImpl.set(java.lang.String)
> a = public javax.ws.rs.core.Response AbstractNameServiceImpl.set(java.lang.String)
> JDK1.7.0_51
> It happens because AnnotationUtils.getAnnotatedMethod has only single argument Method,
that is only from super class AbstractNameServiceImpl and does not check hierarchy of the
NameServiceImpl itself.
> AnnotationUtils.getAnnotatedMethod needs additional Class<?> serviceClass argument
for this purpose.
> It actually affects ResourceUtils.createClassResourceInfo
> that calls AnnotationUtils.getAnnotatedMethod to detect annotated method in the loop
>     private static void evaluateResourceClass(ClassResourceInfo cri, boolean enableStatic)
{
>         MethodDispatcher md = new MethodDispatcher();
>         for (Method m : cri.getServiceClass().getMethods()) {
>             
>             Method annotatedMethod = AnnotationUtils.getAnnotatedMethod(m);
> It knows about ServiceClass, but does not use this information to walk in classes hierarchy.
> For me, this bug leads to the situation that not all methods have mapping in the application.



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

Mime
View raw message