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



##########
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:
       @gitchenjh If it can work in Spring Boot <2.2.0, it is more compatible 
to use ConditionalOnAvailableEndpoint directly. The only problem is that the 
code is a bit difficult to understand.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to