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 <jhq0812@gmail.com>
This commit is contained in:
jkoChen 2024-05-08 15:20:54 +08:00 committed by GitHub
parent 84193247be
commit 5d916cd2c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 14 deletions

View File

@ -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);
}
}