You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2020/03/24 08:26:57 UTC

[cxf] 02/05: Bridge/synthetic methods may not have the parameter annotations, search for the actual method to use

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 959d319e90a10ebd0817b5683a49fdffb298bd06
Author: Daniel Kulp <dk...@apache.org>
AuthorDate: Mon Mar 23 15:01:09 2020 -0400

    Bridge/synthetic methods may not have the parameter annotations, search for the actual method to use
    
    (cherry picked from commit 2e436324dcda546e6c2d11a878bea84bcfc62de1)
---
 .../apache/cxf/jaxrs/utils/AnnotationUtils.java    | 25 +++++++++++++---------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
index ca5766e..67d2a3c 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
@@ -189,19 +189,24 @@ public final class AnnotationUtils {
     private static Method doGetAnnotatedMethod(Class<?> serviceClass, Method m) {
 
         if (m != null) {
-            for (Annotation a : m.getAnnotations()) {
-                if (AnnotationUtils.isMethodAnnotation(a)) {
-                    return m;
+            if (!m.isBridge() && !m.isSynthetic()) {
+                //the bridge/synthetic methods may not have the parameter annotations
+                //thus we will need to search the super classes/interfaces to make 
+                //sure we get the proper method that would also have the parameters annotated
+                //properly
+                for (Annotation a : m.getAnnotations()) {
+                    if (AnnotationUtils.isMethodAnnotation(a)) {
+                        return m;
+                    }
                 }
-            }
-            for (Annotation[] paramAnnotations : m.getParameterAnnotations()) {
-                if (isValidParamAnnotations(paramAnnotations)) {
-                    LOG.warning("Method " + m.getName() + " in " + m.getDeclaringClass().getName()
-                                 + " has no JAX-RS Path or HTTP Method annotations");
-                    return m;
+                for (Annotation[] paramAnnotations : m.getParameterAnnotations()) {
+                    if (isValidParamAnnotations(paramAnnotations)) {
+                        LOG.warning("Method " + m.getName() + " in " + m.getDeclaringClass().getName()
+                                     + " has no JAX-RS Path or HTTP Method annotations");
+                        return m;
+                    }
                 }
             }
-
             Class<?> declaringClass = m.getDeclaringClass();
             Class<?> superC = declaringClass.getSuperclass();
             if (superC != null && Object.class != superC) {