kylixs commented on a change in pull request #9426:
URL: https://github.com/apache/dubbo/pull/9426#discussion_r770298217



##########
File path: 
dubbo-spring-boot/dubbo-spring-boot-actuator/src/main/java/org/apache/dubbo/spring/boot/actuate/endpoint/condition/CompatibleOnEnabledEndpointCondition.java
##########
@@ -35,35 +36,33 @@
  */
 class CompatibleOnEnabledEndpointCondition implements Condition {
 
-    static String[] CONDITION_CLASS_NAMES = {
-            
"org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnAvailableEndpointCondition",
 // 2.2.0+
-            
"org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition"
 // [2.0.0 , 2.2.x]
-    };
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(CompatibleOnEnabledEndpointCondition.class);
+
+    // Spring Boot [2.0.0 , 2.2.x]
+    static String CONDITION_CLASS_NAME_OLD =
+        
"org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnEnabledEndpointCondition";
+
+    // Spring Boot 2.2.0 +
+    static String CONDITION_CLASS_NAME_NEW =
+        
"org.springframework.boot.actuate.autoconfigure.endpoint.condition.OnAvailableEndpointCondition";
 
 
     @Override
     public boolean matches(ConditionContext context, AnnotatedTypeMetadata 
metadata) {
         ClassLoader classLoader = context.getClassLoader();
-
-        Condition condition = Stream.of(CONDITION_CLASS_NAMES)                 
        // Iterate class names
-                .filter(className -> ClassUtils.isPresent(className, 
classLoader))     // Search class existing or not by name
-                .findFirst()                                                   
        // Find the first candidate
-                .map(className -> ClassUtils.resolveClassName(className, 
classLoader)) // Resolve class name to Class
-                .filter(Condition.class::isAssignableFrom)                     
        // Accept the Condition implementation
-                .map(BeanUtils::instantiateClass)                              
        // Instantiate Class to be instance
-                .map(Condition.class::cast)                                    
        // Cast the instance to be Condition one
-                .orElse(NegativeCondition.INSTANCE);                           
        // Or else get a negative condition
-
-        return condition.matches(context, metadata);

Review comment:
       Please try fix error  of `condition.matches(context, metadata)` of 
`OnAvailableEndpointCondition` by add required attributes or re-construct the 
metadata, to compatible with spring boot 2.2.0+ and 2.6.1+.
   
   //OnAvailableEndpointCondition  of Spring Boot 2.6.1
   ```java
        @Override
        public ConditionOutcome getMatchOutcome(ConditionContext context, 
AnnotatedTypeMetadata metadata) {
                Environment environment = context.getEnvironment();
                MergedAnnotation<ConditionalOnAvailableEndpoint> 
conditionAnnotation = metadata.getAnnotations()
                                .get(ConditionalOnAvailableEndpoint.class);
                Class<?> target = getTarget(context, metadata, 
conditionAnnotation);
                MergedAnnotation<Endpoint> endpointAnnotation = 
getEndpointAnnotation(target);
                return getMatchOutcome(environment, conditionAnnotation, 
endpointAnnotation);
        }
   ```
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org
For additional commands, e-mail: notifications-h...@dubbo.apache.org

Reply via email to