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

zrlw pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.3 by this push:
     new 6571e82416 Fix the issue where MergedAnnotation is null when retrieved 
in Spring 5.x (#15581)
6571e82416 is described below

commit 6571e824161980a5357e3284cf2b8fcb9b2395cd
Author: jkoChen <[email protected]>
AuthorDate: Fri Jul 25 09:46:33 2025 +0800

    Fix the issue where MergedAnnotation is null when retrieved in Spring 5.x 
(#15581)
    
    Added compatibility support for Spring 5.x in the method 
org.apache.dubbo.config.spring.util.AnnotationUtils#tryGetMergedAnnotation to 
ensure that MergedAnnotations can be correctly retrieved in Spring 5.x 
environments
---
 .../dubbo/config/spring/util/AnnotationUtils.java  | 38 +++++++++++++---------
 1 file changed, 23 insertions(+), 15 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 953b2cf3b4..a8b141658e 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
@@ -631,22 +631,30 @@ public abstract class AnnotationUtils {
 
         if (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);
+            // getMergedAnnotation method appears in the Spring Framework 5.x
+            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);
+            } else {
+                // getMergedAnnotation method appears in the Spring Framework 
4.2
+                getMergedAnnotationMethod = findMethod(
+                        annotatedElementUtilsClass,
+                        "getMergedAnnotation",
+                        AnnotatedElement.class,
+                        Class.class,
+                        boolean.class,
+                        boolean.class);
+                if (getMergedAnnotationMethod != null) {
+                    mergedAnnotation = (Annotation) invokeMethod(
+                            getMergedAnnotationMethod,
+                            null,
+                            annotatedElement,
+                            annotationType,
+                            classValuesAsString,
+                            nestedAnnotationsAsMap);
+                }
             }
         }
 

Reply via email to