From 5d916cd2c10ad3f21290bf25e338261c30cafbad Mon Sep 17 00:00:00 2001 From: jkoChen <37362859+jkoChen@users.noreply.github.com> Date: Wed, 8 May 2024 15:20:54 +0800 Subject: [PATCH] fix: fix the signature error when using reflection to access the org.springframework.core.annotation.AnnotatedElementUtils#getMergedAnnotation method (#14156) Fix the problem,the method org.apache.dubbo.config.spring.util.AnnotationUtils#tryGetMergedAnnotation utilizes reflection to access org.springframework.core.annotation.AnnotatedElementUtils#getMergedAnnotation. However, there is a signature mismatch in the method's input parameters, which leads to an inability to retrieve the correct method. Consequently, this results in the failure to obtain the mergedAnnotation. Co-authored-by: Albumen Kevin --- .../config/spring/util/AnnotationUtils.java | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/AnnotationUtils.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/AnnotationUtils.java index 02771ca121..35c1bfa932 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/AnnotationUtils.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/util/AnnotationUtils.java @@ -444,21 +444,11 @@ public abstract class AnnotationUtils { (_k) -> ClassUtils.isPresent(ANNOTATED_ELEMENT_UTILS_CLASS_NAME, classLoader))) { Class annotatedElementUtilsClass = resolveClassName(ANNOTATED_ELEMENT_UTILS_CLASS_NAME, classLoader); // getMergedAnnotation method appears in the Spring Framework 4.2 - Method getMergedAnnotationMethod = findMethod( - annotatedElementUtilsClass, - "getMergedAnnotation", - AnnotatedElement.class, - Class.class, - boolean.class, - boolean.class); + Method getMergedAnnotationMethod = + findMethod(annotatedElementUtilsClass, "getMergedAnnotation", AnnotatedElement.class, Class.class); if (getMergedAnnotationMethod != null) { - mergedAnnotation = (Annotation) invokeMethod( - getMergedAnnotationMethod, - null, - annotatedElement, - annotationType, - classValuesAsString, - nestedAnnotationsAsMap); + mergedAnnotation = + (Annotation) invokeMethod(getMergedAnnotationMethod, null, annotatedElement, annotationType); } }