From 1d808c6609cd8b82c3888cfcaf2110d68197f29e Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 08:45:34 +0800 Subject: [PATCH 01/35] Bump project version to 0.2.4-SNAPSHOT Update the property in pom.xml to prepare for the next development iteration. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a43647f..9ea2e81 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ - 0.2.3-SNAPSHOT + 0.2.4-SNAPSHOT 17 From e8ff82147f072b55985e2d3288b50103d508bc3c Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 08:47:00 +0800 Subject: [PATCH 02/35] Add constants for reactive discovery client auto configs Introduced constants for SimpleReactiveDiscoveryClientAutoConfiguration and ReactiveCompositeDiscoveryClientAutoConfiguration class names in DiscoveryClientConstants. This improves maintainability and consistency when referencing these class names. --- .../constants/DiscoveryClientConstants.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/constants/DiscoveryClientConstants.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/constants/DiscoveryClientConstants.java index 505c5a9..5cce42f 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/constants/DiscoveryClientConstants.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/constants/DiscoveryClientConstants.java @@ -20,6 +20,8 @@ import org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient; +import org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration; +import org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryClientAutoConfiguration; /** * The constants for {@link DiscoveryClient} @@ -56,4 +58,18 @@ public interface DiscoveryClientConstants { * @see org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration */ String REACTIVE_COMMONS_CLIENT_AUTO_CONFIGURATION_CLASS_NAME = "org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration"; + + /** + * The class name of {@link SimpleReactiveDiscoveryClientAutoConfiguration} + * + * @see org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryClientAutoConfiguration + */ + String SIMPLE_REACTIVE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME = "org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryClientAutoConfiguration"; + + /** + * The class name of {@link ReactiveCompositeDiscoveryClientAutoConfiguration} + * + * @see org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration + */ + String REACTIVE_COMPOSITE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME = "org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration"; } \ No newline at end of file From e9c4aba3f853ff33144ef7968d4794940c59ddc1 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 08:47:05 +0800 Subject: [PATCH 03/35] Add tests for new reactive discovery client constants Added assertions for SIMPLE_REACTIVE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME and REACTIVE_COMPOSITE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME in DiscoveryClientConstantsTest to improve test coverage for recently introduced constants. --- .../discovery/constants/DiscoveryClientConstantsTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/constants/DiscoveryClientConstantsTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/constants/DiscoveryClientConstantsTest.java index b92ae18..131a2c1 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/constants/DiscoveryClientConstantsTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/constants/DiscoveryClientConstantsTest.java @@ -22,6 +22,8 @@ import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.COMPOSITE_DISCOVERY_CLIENT_CLASS_NAME; import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.DISCOVERY_CLIENT_CLASS_NAME; import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.REACTIVE_COMMONS_CLIENT_AUTO_CONFIGURATION_CLASS_NAME; +import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.REACTIVE_COMPOSITE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME; +import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.SIMPLE_REACTIVE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME; import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -39,5 +41,7 @@ void testConstants() { assertEquals("org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient", COMPOSITE_DISCOVERY_CLIENT_CLASS_NAME); assertEquals("org.springframework.cloud.client.CommonsClientAutoConfiguration", COMMONS_CLIENT_AUTO_CONFIGURATION_CLASS_NAME); assertEquals("org.springframework.cloud.client.ReactiveCommonsClientAutoConfiguration", REACTIVE_COMMONS_CLIENT_AUTO_CONFIGURATION_CLASS_NAME); + assertEquals("org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryClientAutoConfiguration", SIMPLE_REACTIVE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME); + assertEquals("org.springframework.cloud.client.discovery.composite.reactive.ReactiveCompositeDiscoveryClientAutoConfiguration", REACTIVE_COMPOSITE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME); } } \ No newline at end of file From 838b9f24e845d907cd09b0b286d39258f546e39e Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 08:47:11 +0800 Subject: [PATCH 04/35] Add @AutoConfigureAfter to ReactiveDiscoveryClientAutoConfiguration Annotated ReactiveDiscoveryClientAutoConfiguration with @AutoConfigureAfter to ensure it is configured after SimpleReactiveDiscoveryClientAutoConfiguration and ReactiveCompositeDiscoveryClientAutoConfiguration. This improves the ordering of auto-configuration classes. --- .../ReactiveDiscoveryClientAutoConfiguration.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/autoconfigure/ReactiveDiscoveryClientAutoConfiguration.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/autoconfigure/ReactiveDiscoveryClientAutoConfiguration.java index ec164f2..26aa7b1 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/autoconfigure/ReactiveDiscoveryClientAutoConfiguration.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/autoconfigure/ReactiveDiscoveryClientAutoConfiguration.java @@ -18,6 +18,7 @@ package io.microsphere.spring.cloud.client.discovery.autoconfigure; import io.microsphere.spring.cloud.client.discovery.ReactiveDiscoveryClientAdapter; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; @@ -30,6 +31,8 @@ import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.DISCOVERY_CLIENT_CLASS_NAME; import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.REACTIVE_COMMONS_CLIENT_AUTO_CONFIGURATION_CLASS_NAME; +import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.REACTIVE_COMPOSITE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME; +import static io.microsphere.spring.cloud.client.discovery.constants.DiscoveryClientConstants.SIMPLE_REACTIVE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME; /** * The Auto-Configuration class for {@link ReactiveDiscoveryClient} @@ -48,6 +51,10 @@ @AutoConfigureBefore(name = { REACTIVE_COMMONS_CLIENT_AUTO_CONFIGURATION_CLASS_NAME }) +@AutoConfigureAfter(name = { + SIMPLE_REACTIVE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME, + REACTIVE_COMPOSITE_DISCOVERY_CLIENT_AUTO_CONFIGURATION_CLASS_NAME +}) public class ReactiveDiscoveryClientAutoConfiguration { @Configuration(proxyBeanMethods = false) From 608b8f284871b50e389300817a10d60a2193daa5 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 09:54:24 +0800 Subject: [PATCH 05/35] Add DiscoveryUtils utility class for service discovery Introduces DiscoveryUtils, a utility class providing helper methods for working with SimpleDiscoveryProperties and SimpleReactiveDiscoveryProperties in Spring Cloud. Includes methods for retrieving instance maps and converting between the two property types. --- .../client/discovery/util/DiscoveryUtils.java | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtils.java diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtils.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtils.java new file mode 100644 index 0000000..dc1dd9f --- /dev/null +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtils.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.microsphere.spring.cloud.client.discovery.util; + +import io.microsphere.annotation.Nonnull; +import io.microsphere.util.Utils; +import org.springframework.cloud.client.DefaultServiceInstance; +import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties; +import org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryProperties; + +import java.util.List; +import java.util.Map; + +import static io.microsphere.reflect.MethodUtils.invokeMethod; + +/** + * The utilities class for Spring Cloud Discovery + * + * @author Mercy + * @see Utils + * @since 1.0.0 + */ +public abstract class DiscoveryUtils implements Utils { + + /** + * Get the instances map from {@link SimpleDiscoveryProperties} + * + * @param properties {@link SimpleDiscoveryProperties} + * @return the instances map + */ + @Nonnull + public static Map> getInstancesMap(SimpleDiscoveryProperties properties) { + return properties.getInstances(); + } + + /** + * Get the instances map from {@link SimpleReactiveDiscoveryProperties} + * + * @param properties {@link SimpleReactiveDiscoveryProperties} + * @return the instances map + */ + @Nonnull + public static Map> getInstancesMap(SimpleReactiveDiscoveryProperties properties) { + return invokeMethod(properties, "getInstances"); + } + + public static SimpleReactiveDiscoveryProperties simpleReactiveDiscoveryProperties(@Nonnull SimpleDiscoveryProperties properties) { + SimpleReactiveDiscoveryProperties simpleReactiveDiscoveryProperties = new SimpleReactiveDiscoveryProperties(); + simpleReactiveDiscoveryProperties.setOrder(properties.getOrder()); + + DefaultServiceInstance local = properties.getLocal(); + DefaultServiceInstance targetLocal = simpleReactiveDiscoveryProperties.getLocal(); + + simpleReactiveDiscoveryProperties.setInstances(getInstancesMap(properties)); + + simpleReactiveDiscoveryProperties.afterPropertiesSet(); + + return simpleReactiveDiscoveryProperties; + } + + /** + * Convert {@link SimpleReactiveDiscoveryProperties} to {@link SimpleDiscoveryProperties} + * + * @param properties {@link SimpleReactiveDiscoveryProperties} + * @return {@link SimpleDiscoveryProperties} + */ + @Nonnull + public static SimpleDiscoveryProperties simpleDiscoveryProperties(@Nonnull SimpleReactiveDiscoveryProperties properties) { + SimpleDiscoveryProperties simpleDiscoveryProperties = new SimpleDiscoveryProperties(); + simpleDiscoveryProperties.setOrder(properties.getOrder()); + + DefaultServiceInstance local = properties.getLocal(); + simpleDiscoveryProperties.setInstance(local.getServiceId(), local.getHost(), local.getPort()); + + Map> instances = invokeMethod(properties, "getInstances"); + simpleDiscoveryProperties.setInstances(instances); + + simpleDiscoveryProperties.afterPropertiesSet(); + + return simpleDiscoveryProperties; + } + + private DiscoveryUtils() { + } +} From dca8d66d467d64403adde308e4372796d5d42c98 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 09:54:28 +0800 Subject: [PATCH 06/35] Add unit tests for DiscoveryUtils utility class Introduces DiscoveryUtilsTest to verify the behavior of DiscoveryUtils methods, including getInstancesMap and simpleDiscoveryProperties, using both SimpleDiscoveryProperties and SimpleReactiveDiscoveryProperties. --- .../discovery/util/DiscoveryUtilsTest.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtilsTest.java diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtilsTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtilsTest.java new file mode 100644 index 0000000..c795655 --- /dev/null +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtilsTest.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.microsphere.spring.cloud.client.discovery.util; + + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.cloud.client.DefaultServiceInstance; +import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties; +import org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryProperties; + +import java.util.List; +import java.util.Map; + +import static io.microsphere.collection.Lists.ofList; +import static io.microsphere.spring.cloud.client.discovery.util.DiscoveryUtils.getInstancesMap; +import static io.microsphere.spring.cloud.client.discovery.util.DiscoveryUtils.simpleDiscoveryProperties; +import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtilsTest.createDefaultServiceInstance; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * {@link DiscoveryUtils} Test + * + * @author Mercy + * @see DiscoveryUtils + * @since 1.0.0 + */ +class DiscoveryUtilsTest { + + private DefaultServiceInstance serviceInstance; + + private SimpleDiscoveryProperties properties; + + @BeforeEach + void setUp() { + this.serviceInstance = createDefaultServiceInstance(); + this.properties = new SimpleDiscoveryProperties(); + Map> instancesMap = this.properties.getInstances(); + instancesMap.put(this.serviceInstance.getInstanceId(), ofList(this.serviceInstance)); + } + + @Test + void testGetInstancesMap() { + Map> instancesMap = getInstancesMap(this.properties); + assertEquals(1, instancesMap.size()); + assertEquals(ofList(this.serviceInstance), instancesMap.get(this.serviceInstance.getInstanceId())); + } + + @Test + void testGetInstancesMapFromSimpleReactiveDiscoveryProperties() { + SimpleReactiveDiscoveryProperties properties = new SimpleReactiveDiscoveryProperties(); + Map> instancesMap = getInstancesMap(properties); + assertTrue(instancesMap.isEmpty()); + + properties.setInstances(this.properties.getInstances()); + instancesMap = getInstancesMap(properties); + assertEquals(1, instancesMap.size()); + assertEquals(ofList(this.serviceInstance), instancesMap.get(this.serviceInstance.getInstanceId())); + } + + @Test + void testSimpleDiscoveryProperties() { + SimpleReactiveDiscoveryProperties properties = new SimpleReactiveDiscoveryProperties(); + properties.setInstances(this.properties.getInstances()); + + SimpleDiscoveryProperties simpleDiscoveryProperties = simpleDiscoveryProperties(properties); + assertEquals(this.properties.getInstances(), simpleDiscoveryProperties.getInstances()); + } +} \ No newline at end of file From 4cdf936bbafb7c043cae08390442e4a331ad862a Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 10:00:00 +0800 Subject: [PATCH 07/35] Add support for SimpleReactiveDiscoveryProperties Extended SimpleServiceRegistry to support both SimpleDiscoveryProperties and SimpleReactiveDiscoveryProperties by overloading constructors and using a utility method to obtain the instances map. This enhances compatibility with reactive discovery configurations. --- .../registry/SimpleServiceRegistry.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistry.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistry.java index 262a4e0..6d90e12 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistry.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistry.java @@ -19,23 +19,27 @@ import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties; +import org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryProperties; import org.springframework.cloud.client.serviceregistry.ServiceRegistry; import java.util.ArrayList; import java.util.List; import java.util.Map; +import static io.microsphere.spring.cloud.client.discovery.util.DiscoveryUtils.getInstancesMap; import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils.getMetadata; import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils.setMetadata; /** - * Simple {@link ServiceRegistry} class that is based on {@link SimpleDiscoveryProperties} to register + * Simple {@link ServiceRegistry} class that is based on {@link SimpleDiscoveryProperties} + * or {@link SimpleReactiveDiscoveryProperties} to register * {@link DefaultRegistration}. * * @author Mercy * @see ServiceRegistry * @see DefaultRegistration * @see SimpleDiscoveryProperties#getInstances() + * @see SimpleReactiveDiscoveryProperties#getInstances() * @since 1.0.0 */ public class SimpleServiceRegistry implements ServiceRegistry { @@ -44,8 +48,16 @@ public class SimpleServiceRegistry implements ServiceRegistry> instancesMap; - public SimpleServiceRegistry(SimpleDiscoveryProperties simpleDiscoveryProperties) { - this.instancesMap = simpleDiscoveryProperties.getInstances(); + public SimpleServiceRegistry(SimpleDiscoveryProperties properties) { + this(getInstancesMap(properties)); + } + + public SimpleServiceRegistry(SimpleReactiveDiscoveryProperties properties) { + this(getInstancesMap(properties)); + } + + public SimpleServiceRegistry(Map> instancesMap) { + this.instancesMap = instancesMap; } @Override From 40ab6b87d81c4e788e22e23d4527d995f340f197 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 10:00:07 +0800 Subject: [PATCH 08/35] Add constructor test for SimpleServiceRegistry Introduces a test for the SimpleServiceRegistry constructor that accepts SimpleReactiveDiscoveryProperties. Also refactors testGetStatus to use testSetStatus for improved clarity. --- .../registry/SimpleServiceRegistryTest.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistryTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistryTest.java index 028a878..1b11e19 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistryTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/registry/SimpleServiceRegistryTest.java @@ -22,10 +22,12 @@ import org.junit.jupiter.api.Test; import org.springframework.cloud.client.DefaultServiceInstance; import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties; +import org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryProperties; import java.util.List; import java.util.Map; +import static io.microsphere.spring.cloud.client.discovery.util.DiscoveryUtils.simpleReactiveDiscoveryProperties; import static io.microsphere.spring.cloud.client.service.registry.DefaultRegistrationTest.createDefaultRegistration; import static io.microsphere.spring.cloud.client.service.registry.SimpleServiceRegistry.STATUS_KEY; import static java.util.Collections.emptyList; @@ -55,6 +57,13 @@ void setUp() { this.registry = new SimpleServiceRegistry(this.properties); } + @Test + void testConstructor() { + SimpleReactiveDiscoveryProperties properties = simpleReactiveDiscoveryProperties(this.properties); + this.registry = new SimpleServiceRegistry(properties); + testDeregister(); + } + @Test void testRegister() { Map> instancesMap = this.properties.getInstances(); @@ -94,10 +103,8 @@ void testSetStatus() { @Test void testGetStatus() { - testRegister(); - String status = "UP"; - this.registry.setStatus(this.registration, status); - assertEquals(status, this.registry.getStatus(this.registration)); + testSetStatus(); + assertEquals(this.registration.getMetadata().get(STATUS_KEY), this.registry.getStatus(this.registration)); } List getInstances(String serviceId) { From da39278a78b1e5c9d97645a3775bbf5fc3269da0 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 10:09:04 +0800 Subject: [PATCH 09/35] Add setProperties method to ServiceInstanceUtils Introduced a utility method to copy properties from a ServiceInstance to a DefaultServiceInstance, streamlining property assignment between these types. --- .../service/util/ServiceInstanceUtils.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java index 2a45429..39143d4 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java @@ -162,6 +162,23 @@ public static String removeMetadata(ServiceInstance serviceInstance, String meta return metadata.remove(metadataName); } + /** + * Set properties from source to target + * + * @param source source {@link ServiceInstance} + * @param target target {@link DefaultServiceInstance} + */ + public static void setProperties(ServiceInstance source, DefaultServiceInstance target) { + target.setInstanceId(source.getInstanceId()); + target.setServiceId(source.getServiceId()); + target.setHost(source.getHost()); + target.setPort(source.getPort()); + target.setSecure(source.isSecure()); + Map metadata = source.getMetadata(); + metadata.clear(); + metadata.putAll(source.getMetadata()); + } + static List parseWebEndpointMappings(String encodedJSON) { if (isBlank(encodedJSON)) { return emptyList(); From 91605f76df3ce5884ff4eedf670f07dd9dd89d3a Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 10:09:09 +0800 Subject: [PATCH 10/35] Add test for setProperties in ServiceInstanceUtilsTest Introduced a new unit test to verify the setProperties method, ensuring that properties are correctly copied between service instances. --- .../client/service/util/ServiceInstanceUtilsTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java index a7f94f9..9c0c943 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java @@ -39,6 +39,7 @@ import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils.parseWebEndpointMappings; import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils.removeMetadata; import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils.setMetadata; +import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils.setProperties; import static io.microsphere.spring.web.metadata.WebEndpointMapping.Kind.SERVLET; import static io.microsphere.spring.web.metadata.WebEndpointMapping.servlet; import static io.microsphere.util.StringUtils.EMPTY_STRING; @@ -144,6 +145,13 @@ void testMetadataOps() { assertNull(getMetadata(this.serviceInstance, WEB_CONTEXT_PATH_METADATA_NAME)); } + @Test + void testSetProperties() { + DefaultServiceInstance target = new DefaultServiceInstance(); + setProperties(this.serviceInstance, target); + assertEquals(this.serviceInstance, target); + } + private Collection createWebEndpointMappings() { return ofList(buildWebEndpointMapping(true)); } From d4ccf71853c0f134e0d701132854db7450cfc623 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 10:25:17 +0800 Subject: [PATCH 11/35] Set URI directly in setProperties method Updated ServiceInstanceUtils.setProperties to set the URI on the target DefaultServiceInstance using getUri(source) instead of setting host, port, and secure individually. --- .../cloud/client/service/util/ServiceInstanceUtils.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java index 39143d4..3cc7db4 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java @@ -171,9 +171,8 @@ public static String removeMetadata(ServiceInstance serviceInstance, String meta public static void setProperties(ServiceInstance source, DefaultServiceInstance target) { target.setInstanceId(source.getInstanceId()); target.setServiceId(source.getServiceId()); - target.setHost(source.getHost()); - target.setPort(source.getPort()); - target.setSecure(source.isSecure()); + URI uri = getUri(source); + target.setUri(uri); Map metadata = source.getMetadata(); metadata.clear(); metadata.putAll(source.getMetadata()); From dc714ce1edf1298b15c1aa5b4a2c70c9f4b643dc Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 10:31:31 +0800 Subject: [PATCH 12/35] Enhance DiscoveryUtils with property copying and null checks Added property copying for DefaultServiceInstance when converting SimpleDiscoveryProperties to SimpleReactiveDiscoveryProperties using setProperties. Also added @Nonnull annotations to method parameters for better null safety. --- .../client/discovery/util/DiscoveryUtils.java | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtils.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtils.java index dc1dd9f..db3a521 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtils.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/util/DiscoveryUtils.java @@ -27,6 +27,7 @@ import java.util.Map; import static io.microsphere.reflect.MethodUtils.invokeMethod; +import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtils.setProperties; /** * The utilities class for Spring Cloud Discovery @@ -44,7 +45,7 @@ public abstract class DiscoveryUtils implements Utils { * @return the instances map */ @Nonnull - public static Map> getInstancesMap(SimpleDiscoveryProperties properties) { + public static Map> getInstancesMap(@Nonnull SimpleDiscoveryProperties properties) { return properties.getInstances(); } @@ -55,20 +56,27 @@ public static Map> getInstancesMap(SimpleDi * @return the instances map */ @Nonnull - public static Map> getInstancesMap(SimpleReactiveDiscoveryProperties properties) { + public static Map> getInstancesMap(@Nonnull SimpleReactiveDiscoveryProperties properties) { return invokeMethod(properties, "getInstances"); } + /** + * Convert {@link SimpleDiscoveryProperties} to {@link SimpleReactiveDiscoveryProperties} + * + * @param properties {@link SimpleDiscoveryProperties} + * @return {@link SimpleReactiveDiscoveryProperties} + */ + @Nonnull public static SimpleReactiveDiscoveryProperties simpleReactiveDiscoveryProperties(@Nonnull SimpleDiscoveryProperties properties) { SimpleReactiveDiscoveryProperties simpleReactiveDiscoveryProperties = new SimpleReactiveDiscoveryProperties(); simpleReactiveDiscoveryProperties.setOrder(properties.getOrder()); DefaultServiceInstance local = properties.getLocal(); DefaultServiceInstance targetLocal = simpleReactiveDiscoveryProperties.getLocal(); + setProperties(targetLocal, local); - simpleReactiveDiscoveryProperties.setInstances(getInstancesMap(properties)); - - simpleReactiveDiscoveryProperties.afterPropertiesSet(); + Map> instances = getInstancesMap(properties); + simpleReactiveDiscoveryProperties.setInstances(instances); return simpleReactiveDiscoveryProperties; } @@ -90,11 +98,9 @@ public static SimpleDiscoveryProperties simpleDiscoveryProperties(@Nonnull Simpl Map> instances = invokeMethod(properties, "getInstances"); simpleDiscoveryProperties.setInstances(instances); - simpleDiscoveryProperties.afterPropertiesSet(); - return simpleDiscoveryProperties; } private DiscoveryUtils() { } -} +} \ No newline at end of file From 7935f59a000c4f831767cf3abfa6dfa146465fd3 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 11:01:33 +0800 Subject: [PATCH 13/35] Default port in URL if ServiceInstance port is invalid Update ServiceInstanceUtils to use port 443 for secure instances and 80 for non-secure instances when the provided port is less than or equal to zero. This ensures generated URLs are always valid even if the ServiceInstance port is not set. --- .../client/service/util/ServiceInstanceUtils.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java index 3cc7db4..d8fa406 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java @@ -51,6 +51,7 @@ import static io.microsphere.util.StringUtils.EMPTY_STRING; import static io.microsphere.util.StringUtils.EMPTY_STRING_ARRAY; import static io.microsphere.util.StringUtils.isBlank; +import static java.lang.String.valueOf; import static java.net.URI.create; import static java.util.Collections.emptyList; @@ -102,12 +103,16 @@ public static String getUriString(ServiceInstance instance) { boolean isSecure = instance.isSecure(); String prefix = isSecure ? "https://" : "http://"; String host = instance.getHost(); - String port = String.valueOf(instance.getPort()); - StringBuilder urlStringBuilder = new StringBuilder((isSecure ? 9 : 8) + host.length() + port.length()); + int port = instance.getPort(); + if (port <= 0) { + port = isSecure ? 443 : 80; + } + String portString = valueOf(port); + StringBuilder urlStringBuilder = new StringBuilder((isSecure ? 9 : 8) + host.length() + portString.length()); urlStringBuilder.append(prefix) .append(host) .append(COLON_CHAR) - .append(port); + .append(portString); return urlStringBuilder.toString(); } From bcd555f22c48cecd6a48a374bd3633570b212630 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 11:01:38 +0800 Subject: [PATCH 14/35] Add tests for getUriString and getUri without port Added test cases to verify getUriString and getUri methods handle URIs without explicit ports, ensuring default ports (80 for HTTP, 443 for HTTPS) are appended as expected. --- .../util/ServiceInstanceUtilsTest.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java index 9c0c943..81b0468 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test; import org.springframework.cloud.client.DefaultServiceInstance; +import java.net.URI; import java.util.Collection; import static io.microsphere.collection.Lists.ofList; @@ -126,11 +127,31 @@ void testGetUriString() { String uriString = "https://localhost:8080"; this.serviceInstance.setUri(create(uriString)); assertEquals(uriString, getUriString(this.serviceInstance)); + + } + + @Test + void testGetUriStringWithoutPort() { + String uriString = "http://localhost"; + this.serviceInstance.setUri(create(uriString)); + assertEquals(uriString + ":80", getUriString(this.serviceInstance)); + + uriString = "https://localhost"; + this.serviceInstance.setUri(create(uriString)); + assertEquals(uriString + ":443", getUriString(this.serviceInstance)); } @Test void testGetUri() { - assertEquals(create("http://localhost:8080"), getUri(this.serviceInstance)); + URI uri = getUri(this.serviceInstance); + assertEquals(create("http://localhost:8080"), uri); + assertEquals(DefaultServiceInstance.getUri(this.serviceInstance), uri); + + uri = create("https://localhost"); + this.serviceInstance.setUri(uri); + uri = getUri(this.serviceInstance); + assertEquals(create("https://localhost:443"), uri); + assertEquals(DefaultServiceInstance.getUri(this.serviceInstance), uri); } @Test From 75aa9017f2f98e8fdce42514b91037635f2443e2 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 11:13:40 +0800 Subject: [PATCH 15/35] Update property mapping in setProperties method Replaces setting URI on target with setting secure, host, and port properties from the source ServiceInstance. This change ensures that DefaultServiceInstance receives these individual properties directly. --- .../cloud/client/service/util/ServiceInstanceUtils.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java index d8fa406..71aab2b 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtils.java @@ -176,8 +176,9 @@ public static String removeMetadata(ServiceInstance serviceInstance, String meta public static void setProperties(ServiceInstance source, DefaultServiceInstance target) { target.setInstanceId(source.getInstanceId()); target.setServiceId(source.getServiceId()); - URI uri = getUri(source); - target.setUri(uri); + target.setSecure(source.isSecure()); + target.setHost(source.getHost()); + target.setPort(source.getPort()); Map metadata = source.getMetadata(); metadata.clear(); metadata.putAll(source.getMetadata()); From 9e3928d53db69f6e851c07e81c26b77ce9dca635 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 11:13:46 +0800 Subject: [PATCH 16/35] Remove unnecessary blank line in ServiceInstanceUtilsTest Cleaned up formatting by deleting an extra blank line in the getUriString test method. --- .../cloud/client/service/util/ServiceInstanceUtilsTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java index 81b0468..ef19431 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/service/util/ServiceInstanceUtilsTest.java @@ -127,7 +127,6 @@ void testGetUriString() { String uriString = "https://localhost:8080"; this.serviceInstance.setUri(create(uriString)); assertEquals(uriString, getUriString(this.serviceInstance)); - } @Test From e8920dd279eaee2231c651be738a7ff2b77a7e54 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 11:52:25 +0800 Subject: [PATCH 17/35] Update pom.xml --- microsphere-spring-cloud-commons/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/microsphere-spring-cloud-commons/pom.xml b/microsphere-spring-cloud-commons/pom.xml index f9869ac..be5392c 100644 --- a/microsphere-spring-cloud-commons/pom.xml +++ b/microsphere-spring-cloud-commons/pom.xml @@ -67,6 +67,11 @@ true + + org.springframework.cloud + spring-cloud-loadbalancer + true + From cc321e8d3dda35aa90b0699ee712b25c2e4a98af Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 11:52:33 +0800 Subject: [PATCH 18/35] Add constant for load balancer enabled property Introduced LOAD_BALANCER_ENABLED_PROPERTY_NAME to represent the 'spring.cloud.loadbalancer.enabled' property, including relevant documentation and configuration property annotation. --- .../constants/SpringCloudPropertyConstants.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstants.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstants.java index bcabfd5..9af29f2 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstants.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstants.java @@ -68,4 +68,17 @@ public interface SpringCloudPropertyConstants { source = APPLICATION_SOURCE ) String FEATURES_ENABLED_PROPERTY_NAME = SPRING_CLOUD_PROPERTY_PREFIX + "features." + ENABLED_PROPERTY_NAME; + + + /** + * The property name for enabling Spring Cloud Load-Balancer : "spring.cloud.loadbalancer.enabled" + * + * @see org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration + */ + @ConfigurationProperty( + type = boolean.class, + defaultValue = "true", + source = APPLICATION_SOURCE + ) + String LOAD_BALANCER_ENABLED_PROPERTY_NAME = SPRING_CLOUD_PROPERTY_PREFIX + "loadbalancer." + ENABLED_PROPERTY_NAME; } \ No newline at end of file From 55195f3aa318da9cf553fe4b19b4df061bdc3751 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 11:52:38 +0800 Subject: [PATCH 19/35] Add unit test for SpringCloudPropertyConstants Introduces SpringCloudPropertyConstantsTest to verify the values of property name constants in SpringCloudPropertyConstants. --- .../SpringCloudPropertyConstantsTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstantsTest.java diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstantsTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstantsTest.java new file mode 100644 index 0000000..aea3674 --- /dev/null +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstantsTest.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.microsphere.spring.cloud.commons.constants; + + +import org.junit.jupiter.api.Test; + +import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.FEATURES_ENABLED_PROPERTY_NAME; +import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.LOAD_BALANCER_ENABLED_PROPERTY_NAME; +import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED_PROPERTY_NAME; +import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.SERVICE_REGISTRY_PROPERTY_PREFIX; +import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.SPRING_CLOUD_PROPERTY_PREFIX; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * {@link SpringCloudPropertyConstants} Test + * + * @author Mercy + * @see SpringCloudPropertyConstants + * @since 1.0.0 + */ +class SpringCloudPropertyConstantsTest { + + @Test + void testConstants() { + assertEquals("spring.cloud.", SPRING_CLOUD_PROPERTY_PREFIX); + assertEquals("spring.cloud.service-registry.", SERVICE_REGISTRY_PROPERTY_PREFIX); + assertEquals("spring.cloud.service-registry.auto-registration.enabled", SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED_PROPERTY_NAME); + assertEquals("spring.cloud.features.enabled", FEATURES_ENABLED_PROPERTY_NAME); + assertEquals("spring.cloud.loadbalancer.enabled", LOAD_BALANCER_ENABLED_PROPERTY_NAME); + } +} \ No newline at end of file From f49d2e45e411b0c476fbbce14037d347bce82e17 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 12:15:56 +0800 Subject: [PATCH 20/35] Add ConditionalOnLoadBalancerEnabled annotation Introduces a custom annotation that meta-annotates @ConditionalOnProperty for enabling LoadBalancer features based on the 'loadbalancer.enabled' property. This simplifies conditional bean registration for LoadBalancer-related components. --- .../ConditionalOnLoadBalancerEnabled.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabled.java diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabled.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabled.java new file mode 100644 index 0000000..5b04c06 --- /dev/null +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabled.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.microsphere.spring.cloud.loadbalancer.condition; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.LOAD_BALANCER_ENABLED_PROPERTY_NAME; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * The conditional annotation meta-annotates {@link ConditionalOnProperty @ConditionalOnProperty} for + * LoadBalancer enabled. + * + * @author Mercy + * @see org.springframework.cloud.loadbalancer.config.LoadBalancerAutoConfiguration + * @see ConditionalOnProperty + * @since 1.0.0 + */ +@Retention(RUNTIME) +@Target({TYPE, METHOD}) +@Documented +@ConditionalOnProperty(name = LOAD_BALANCER_ENABLED_PROPERTY_NAME, havingValue = "true", matchIfMissing = true) +public @interface ConditionalOnLoadBalancerEnabled { +} \ No newline at end of file From 4a73fd386f4d251b529ff4b03e54f5312e1391f9 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 12:16:00 +0800 Subject: [PATCH 21/35] Add test for ConditionalOnLoadBalancerEnabled Introduces a unit test to verify the behavior of the @ConditionalOnLoadBalancerEnabled annotation, ensuring the Config bean is conditionally present based on the 'spring.cloud.loadbalancer.enabled' property. --- .../ConditionalOnLoadBalancerEnabledTest.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java new file mode 100644 index 0000000..6a87e4a --- /dev/null +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.microsphere.spring.cloud.loadbalancer.condition; + +import org.junit.jupiter.api.Test; + +import java.util.Properties; + +import static com.alibaba.spring.util.BeanUtils.isBeanPresent; +import static io.microsphere.spring.test.util.SpringTestUtils.testInSpringContainer; +import static java.lang.System.getProperties; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * {@link ConditionalOnLoadBalancerEnabled @ConditionalOnLoadBalancerEnabled} Test + * + * @author Mercy + * @see ConditionalOnLoadBalancerEnabled + * @since 1.0.0 + */ +public class ConditionalOnLoadBalancerEnabledTest { + + @ConditionalOnLoadBalancerEnabled + static class Config { + } + + @Test + void testConfigBeanPresent() { + testConfigBean(true); + } + + @Test + void testConfigBeanAbsent() { + Properties properties = getProperties(); + try { + properties.setProperty("spring.cloud.loadbalancer.enabled", "false"); + testConfigBean(false); + } finally { + properties.remove("spring.cloud.loadbalancer.enabled"); + } + } + + void testConfigBean(boolean present) { + testInSpringContainer(context -> { + assertEquals(present, isBeanPresent(context, Config.class)); + }, Config.class); + } +} From 2d51c53437dd032469b79647fadc33862d3da174 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 13:12:13 +0800 Subject: [PATCH 22/35] Add property constant for Spring Cloud Util enablement Introduced UTIL_ENABLED_PROPERTY_NAME for enabling or disabling Spring Cloud Util via the 'spring.cloud.util.enabled' property. This addition aligns with the existing pattern for feature toggles and references UtilAutoConfiguration. --- .../constants/SpringCloudPropertyConstants.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstants.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstants.java index 9af29f2..0fce3f3 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstants.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstants.java @@ -20,6 +20,7 @@ import io.microsphere.annotation.ConfigurationProperty; import org.springframework.cloud.client.CommonsClientAutoConfiguration; import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationAutoConfiguration; +import org.springframework.cloud.commons.util.UtilAutoConfiguration; import static io.microsphere.annotation.ConfigurationProperty.APPLICATION_SOURCE; import static io.microsphere.constants.PropertyConstants.ENABLED_PROPERTY_NAME; @@ -69,7 +70,6 @@ public interface SpringCloudPropertyConstants { ) String FEATURES_ENABLED_PROPERTY_NAME = SPRING_CLOUD_PROPERTY_PREFIX + "features." + ENABLED_PROPERTY_NAME; - /** * The property name for enabling Spring Cloud Load-Balancer : "spring.cloud.loadbalancer.enabled" * @@ -81,4 +81,17 @@ public interface SpringCloudPropertyConstants { source = APPLICATION_SOURCE ) String LOAD_BALANCER_ENABLED_PROPERTY_NAME = SPRING_CLOUD_PROPERTY_PREFIX + "loadbalancer." + ENABLED_PROPERTY_NAME; + + + /** + * The property name for enabling Spring Cloud Util : "spring.cloud.util.enabled" + * + * @see UtilAutoConfiguration + */ + @ConfigurationProperty( + type = boolean.class, + defaultValue = "true", + source = APPLICATION_SOURCE + ) + String UTIL_ENABLED_PROPERTY_NAME = SPRING_CLOUD_PROPERTY_PREFIX + "util." + ENABLED_PROPERTY_NAME; } \ No newline at end of file From 28df5846c0e781694a53bd23b1fc8122eafa901d Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 13:12:23 +0800 Subject: [PATCH 23/35] Add test for UTIL_ENABLED_PROPERTY_NAME constant Added an assertion to verify the value of UTIL_ENABLED_PROPERTY_NAME in SpringCloudPropertyConstantsTest to ensure the constant is correctly defined. --- .../commons/constants/SpringCloudPropertyConstantsTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstantsTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstantsTest.java index aea3674..41b9a19 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstantsTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/constants/SpringCloudPropertyConstantsTest.java @@ -25,6 +25,7 @@ import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED_PROPERTY_NAME; import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.SERVICE_REGISTRY_PROPERTY_PREFIX; import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.SPRING_CLOUD_PROPERTY_PREFIX; +import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.UTIL_ENABLED_PROPERTY_NAME; import static org.junit.jupiter.api.Assertions.assertEquals; /** @@ -43,5 +44,6 @@ void testConstants() { assertEquals("spring.cloud.service-registry.auto-registration.enabled", SERVICE_REGISTRY_AUTO_REGISTRATION_ENABLED_PROPERTY_NAME); assertEquals("spring.cloud.features.enabled", FEATURES_ENABLED_PROPERTY_NAME); assertEquals("spring.cloud.loadbalancer.enabled", LOAD_BALANCER_ENABLED_PROPERTY_NAME); + assertEquals("spring.cloud.util.enabled", UTIL_ENABLED_PROPERTY_NAME); } } \ No newline at end of file From adf8b37233dfbfb087793df94edf29ecd41e121c Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 13:12:32 +0800 Subject: [PATCH 24/35] Refactor ConditionalOnLoadBalancerEnabledTest class usage Moved the @ConditionalOnLoadBalancerEnabled annotation from the inner Config class to the test class itself. Updated testConfigBean to reference the test class instead of the inner Config class, simplifying the test structure. --- .../condition/ConditionalOnLoadBalancerEnabledTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java index 6a87e4a..d794f30 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java @@ -33,12 +33,9 @@ * @see ConditionalOnLoadBalancerEnabled * @since 1.0.0 */ +@ConditionalOnLoadBalancerEnabled public class ConditionalOnLoadBalancerEnabledTest { - @ConditionalOnLoadBalancerEnabled - static class Config { - } - @Test void testConfigBeanPresent() { testConfigBean(true); @@ -57,7 +54,7 @@ void testConfigBeanAbsent() { void testConfigBean(boolean present) { testInSpringContainer(context -> { - assertEquals(present, isBeanPresent(context, Config.class)); - }, Config.class); + assertEquals(present, isBeanPresent(context, getClass())); + }, getClass()); } } From 348a220dd2485e3488939e62f42afc730dea041e Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 13:13:10 +0800 Subject: [PATCH 25/35] Add ConditionalOnUtilEnabled annotation Introduces a custom annotation that meta-annotates @ConditionalOnProperty for UtilAutoConfiguration, enabling conditional configuration based on the UTIL_ENABLED_PROPERTY_NAME property. --- .../condition/ConditionalOnUtilEnabled.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabled.java diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabled.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabled.java new file mode 100644 index 0000000..a24ed4c --- /dev/null +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabled.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.microsphere.spring.cloud.commons.condition; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cloud.commons.util.UtilAutoConfiguration; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static io.microsphere.spring.cloud.commons.constants.SpringCloudPropertyConstants.UTIL_ENABLED_PROPERTY_NAME; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * The conditional annotation meta-annotates {@link ConditionalOnProperty @ConditionalOnProperty} for + * {@link UtilAutoConfiguration} enabled. + * + * @author Mercy + * @see UtilAutoConfiguration + * @see ConditionalOnProperty + * @since 1.0.0 + */ +@Retention(RUNTIME) +@Target({TYPE, METHOD}) +@Documented +@ConditionalOnProperty(name = UTIL_ENABLED_PROPERTY_NAME, matchIfMissing = true) +public @interface ConditionalOnUtilEnabled { +} \ No newline at end of file From 07a6b8bd6a164ed5470f38b31c892c0ad1b59e8b Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 13:13:16 +0800 Subject: [PATCH 26/35] Add test for ConditionalOnUtilEnabled annotation Introduces ConditionalOnUtilEnabledTest to verify bean presence based on the 'spring.cloud.util.enabled' property. Ensures correct conditional behavior in Spring container. --- .../ConditionalOnUtilEnabledTest.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java new file mode 100644 index 0000000..74bd864 --- /dev/null +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.microsphere.spring.cloud.commons.condition; + +import org.junit.jupiter.api.Test; + +import java.util.Properties; + +import static com.alibaba.spring.util.BeanUtils.isBeanPresent; +import static io.microsphere.spring.test.util.SpringTestUtils.testInSpringContainer; +import static java.lang.System.getProperties; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * {@link ConditionalOnUtilEnabled} Test + * + * @author Mercy + * @see ConditionalOnUtilEnabled + * @since 1.0.0 + */ +@ConditionalOnUtilEnabled +public class ConditionalOnUtilEnabledTest { + + @Test + void testConfigBeanPresent() { + testConfigBean(true); + } + + @Test + void testConfigBeanAbsent() { + Properties properties = getProperties(); + try { + properties.setProperty("spring.cloud.util.enabled", "false"); + testConfigBean(false); + } finally { + properties.remove("spring.cloud.util.enabled"); + } + } + + void testConfigBean(boolean present) { + testInSpringContainer(context -> { + assertEquals(present, isBeanPresent(context, getClass())); + }, getClass()); + } +} From 1ae89291692b918dffd19fbe6f015563c80cbe24 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 13:23:18 +0800 Subject: [PATCH 27/35] Fix test class reference in condition test cases Replaces usage of getClass() with explicit test class references in ConditionalOnUtilEnabledTest and ConditionalOnLoadBalancerEnabledTest to ensure correct bean presence checks. --- .../cloud/commons/condition/ConditionalOnUtilEnabledTest.java | 4 ++-- .../condition/ConditionalOnLoadBalancerEnabledTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java index 74bd864..f92cb37 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java @@ -54,7 +54,7 @@ void testConfigBeanAbsent() { void testConfigBean(boolean present) { testInSpringContainer(context -> { - assertEquals(present, isBeanPresent(context, getClass())); - }, getClass()); + assertEquals(present, isBeanPresent(context, ConditionalOnUtilEnabledTest.class)); + }, ConditionalOnUtilEnabledTest.class); } } diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java index d794f30..959565a 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java @@ -54,7 +54,7 @@ void testConfigBeanAbsent() { void testConfigBean(boolean present) { testInSpringContainer(context -> { - assertEquals(present, isBeanPresent(context, getClass())); - }, getClass()); + assertEquals(present, isBeanPresent(context, ConditionalOnLoadBalancerEnabledTest.class)); + }, ConditionalOnLoadBalancerEnabledTest.class); } } From 37cb99c3eb1a4d152a53ee9aafe97eca58a01a31 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 13:23:35 +0800 Subject: [PATCH 28/35] Update ConditionalOnUtilEnabledTest.java --- .../cloud/commons/condition/ConditionalOnUtilEnabledTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java index f92cb37..4f9696c 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java @@ -57,4 +57,4 @@ void testConfigBean(boolean present) { assertEquals(present, isBeanPresent(context, ConditionalOnUtilEnabledTest.class)); }, ConditionalOnUtilEnabledTest.class); } -} +} \ No newline at end of file From 4a86a66e0b0c93dde01c1f08f3855796862908a3 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 13:23:48 +0800 Subject: [PATCH 29/35] Update ConditionalOnLoadBalancerEnabledTest.java --- .../condition/ConditionalOnLoadBalancerEnabledTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java index 959565a..f9d1cca 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java @@ -57,4 +57,4 @@ void testConfigBean(boolean present) { assertEquals(present, isBeanPresent(context, ConditionalOnLoadBalancerEnabledTest.class)); }, ConditionalOnLoadBalancerEnabledTest.class); } -} +} \ No newline at end of file From 0f8b69f0f9d423081223b459c58e1f59ef8375bc Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 15:40:13 +0800 Subject: [PATCH 30/35] Update BeanUtils import to microsphere package in tests Replaced imports of isBeanPresent from com.alibaba.spring.util.BeanUtils with io.microsphere.spring.beans.BeanUtils in ConditionalOnUtilEnabledTest and ConditionalOnLoadBalancerEnabledTest to reflect package changes. --- .../cloud/commons/condition/ConditionalOnUtilEnabledTest.java | 2 +- .../condition/ConditionalOnLoadBalancerEnabledTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java index 4f9696c..14a9895 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java @@ -21,7 +21,7 @@ import java.util.Properties; -import static com.alibaba.spring.util.BeanUtils.isBeanPresent; +import static io.microsphere.spring.beans.BeanUtils.isBeanPresent; import static io.microsphere.spring.test.util.SpringTestUtils.testInSpringContainer; import static java.lang.System.getProperties; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java index f9d1cca..831dc36 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java @@ -21,7 +21,7 @@ import java.util.Properties; -import static com.alibaba.spring.util.BeanUtils.isBeanPresent; +import static io.microsphere.spring.beans.BeanUtils.isBeanPresent; import static io.microsphere.spring.test.util.SpringTestUtils.testInSpringContainer; import static java.lang.System.getProperties; import static org.junit.jupiter.api.Assertions.assertEquals; From 754e504bbe6cd5fd124fb4af00a4836b8fe1d3ba Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 17:18:42 +0800 Subject: [PATCH 31/35] Refactor conditional property tests to use shared base class Introduced ConditionalOnPropertyEnabledTest as a reusable abstract test class for @ConditionalOnProperty-based conditions. Updated ConditionalOnFeaturesEnabledTest, ConditionalOnUtilEnabledTest, and ConditionalOnLoadBalancerEnabledTest to extend this new base class, reducing code duplication and improving maintainability. Also set matchIfMissing=true for ConditionalOnFeaturesEnabled. --- .../ConditionalOnFeaturesEnabled.java | 2 +- .../ConditionalOnFeaturesEnabledTest.java | 34 +---- .../ConditionalOnUtilEnabledTest.java | 33 +---- .../ConditionalOnLoadBalancerEnabledTest.java | 33 +---- .../ConditionalOnPropertyEnabledTest.java | 122 ++++++++++++++++++ 5 files changed, 130 insertions(+), 94 deletions(-) create mode 100644 microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/test/ConditionalOnPropertyEnabledTest.java diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabled.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabled.java index 1ce3f27..fcfb14b 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabled.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabled.java @@ -47,7 +47,7 @@ @Retention(RUNTIME) @Target({TYPE, METHOD}) @Documented -@ConditionalOnProperty(name = FEATURES_ENABLED_PROPERTY_NAME) +@ConditionalOnProperty(name = FEATURES_ENABLED_PROPERTY_NAME, matchIfMissing = true) public @interface ConditionalOnFeaturesEnabled { /** diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabledTest.java index 6e57810..80986d9 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabledTest.java @@ -24,36 +24,8 @@ * @since 1.0.0 */ -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit.jupiter.SpringExtension; +import io.microsphere.spring.cloud.test.ConditionalOnPropertyEnabledTest; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@ExtendWith(SpringExtension.class) -@ContextConfiguration(classes = { - ConditionalOnFeaturesEnabledTest.FeaturesConfiguration.class -}) -@TestPropertySource( - properties = { - "spring.cloud.features.enabled=true" - } -) -class ConditionalOnFeaturesEnabledTest { - - @ConditionalOnFeaturesEnabled - static class FeaturesConfiguration { - } - - @Autowired - private ObjectProvider featuresConfigurationProvider; - - @Test - void test() { - assertNotNull(featuresConfigurationProvider.getIfAvailable()); - } +@ConditionalOnFeaturesEnabled +class ConditionalOnFeaturesEnabledTest extends ConditionalOnPropertyEnabledTest { } diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java index 14a9895..ce62854 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/commons/condition/ConditionalOnUtilEnabledTest.java @@ -17,14 +17,7 @@ package io.microsphere.spring.cloud.commons.condition; -import org.junit.jupiter.api.Test; - -import java.util.Properties; - -import static io.microsphere.spring.beans.BeanUtils.isBeanPresent; -import static io.microsphere.spring.test.util.SpringTestUtils.testInSpringContainer; -import static java.lang.System.getProperties; -import static org.junit.jupiter.api.Assertions.assertEquals; +import io.microsphere.spring.cloud.test.ConditionalOnPropertyEnabledTest; /** * {@link ConditionalOnUtilEnabled} Test @@ -34,27 +27,5 @@ * @since 1.0.0 */ @ConditionalOnUtilEnabled -public class ConditionalOnUtilEnabledTest { - - @Test - void testConfigBeanPresent() { - testConfigBean(true); - } - - @Test - void testConfigBeanAbsent() { - Properties properties = getProperties(); - try { - properties.setProperty("spring.cloud.util.enabled", "false"); - testConfigBean(false); - } finally { - properties.remove("spring.cloud.util.enabled"); - } - } - - void testConfigBean(boolean present) { - testInSpringContainer(context -> { - assertEquals(present, isBeanPresent(context, ConditionalOnUtilEnabledTest.class)); - }, ConditionalOnUtilEnabledTest.class); - } +public class ConditionalOnUtilEnabledTest extends ConditionalOnPropertyEnabledTest { } \ No newline at end of file diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java index 831dc36..d251003 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/loadbalancer/condition/ConditionalOnLoadBalancerEnabledTest.java @@ -17,14 +17,7 @@ package io.microsphere.spring.cloud.loadbalancer.condition; -import org.junit.jupiter.api.Test; - -import java.util.Properties; - -import static io.microsphere.spring.beans.BeanUtils.isBeanPresent; -import static io.microsphere.spring.test.util.SpringTestUtils.testInSpringContainer; -import static java.lang.System.getProperties; -import static org.junit.jupiter.api.Assertions.assertEquals; +import io.microsphere.spring.cloud.test.ConditionalOnPropertyEnabledTest; /** * {@link ConditionalOnLoadBalancerEnabled @ConditionalOnLoadBalancerEnabled} Test @@ -34,27 +27,5 @@ * @since 1.0.0 */ @ConditionalOnLoadBalancerEnabled -public class ConditionalOnLoadBalancerEnabledTest { - - @Test - void testConfigBeanPresent() { - testConfigBean(true); - } - - @Test - void testConfigBeanAbsent() { - Properties properties = getProperties(); - try { - properties.setProperty("spring.cloud.loadbalancer.enabled", "false"); - testConfigBean(false); - } finally { - properties.remove("spring.cloud.loadbalancer.enabled"); - } - } - - void testConfigBean(boolean present) { - testInSpringContainer(context -> { - assertEquals(present, isBeanPresent(context, ConditionalOnLoadBalancerEnabledTest.class)); - }, ConditionalOnLoadBalancerEnabledTest.class); - } +public class ConditionalOnLoadBalancerEnabledTest extends ConditionalOnPropertyEnabledTest { } \ No newline at end of file diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/test/ConditionalOnPropertyEnabledTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/test/ConditionalOnPropertyEnabledTest.java new file mode 100644 index 0000000..42ec97f --- /dev/null +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/test/ConditionalOnPropertyEnabledTest.java @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.microsphere.spring.cloud.test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Conditional; +import org.springframework.core.annotation.AnnotationAttributes; +import org.springframework.core.type.AnnotationMetadata; + +import java.util.Properties; +import java.util.Set; + +import static io.microsphere.collection.SetUtils.newLinkedHashSet; +import static io.microsphere.spring.beans.BeanUtils.isBeanPresent; +import static io.microsphere.spring.core.annotation.AnnotationUtils.getAnnotationAttributes; +import static io.microsphere.spring.test.util.SpringTestUtils.testInSpringContainer; +import static io.microsphere.util.ArrayUtils.isEmpty; +import static java.lang.String.valueOf; +import static java.lang.System.getProperties; +import static org.apache.commons.io.IOUtils.length; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.springframework.core.type.AnnotationMetadata.introspect; +import static org.springframework.util.StringUtils.hasText; + +/** + * Abstract test class for {@link ConditionalOnProperty @ConditionalOnProperty} On Enabled + * + * @author Mercy + * @see ConditionalOnProperty + * @since 1.0.0 + */ +public abstract class ConditionalOnPropertyEnabledTest { + + private AnnotationAttributes annotationAttributes; + + @BeforeEach + void setUp() { + AnnotationMetadata annotationMetadata = introspect(getClass()); + this.annotationAttributes = getAnnotationAttributes(annotationMetadata, ConditionalOnProperty.class); + } + + @Test + void testConditionalOnPropertyEnabled() { + if (matchIfMissing()) { + testBean(true); + } else { + testConditionalOnPropertyEnabled(true); + } + } + + @Test + void testConditionalOnPropertyDisabled() { + testConditionalOnPropertyEnabled(false); + } + + /** + * Whether match if missing + * + * @return {@code true} if match if missing + */ + protected boolean matchIfMissing() { + return this.annotationAttributes.getBoolean("matchIfMissing"); + } + + /** + * Get the property names of the {@link Conditional @Conditional} + * + * @return property names + */ + protected Set getPropertyNames() { + String prefix = this.annotationAttributes.getString("prefix"); + String[] names = this.annotationAttributes.getStringArray("name"); + if (isEmpty(names)) { + names = this.annotationAttributes.getStringArray("value"); + } + boolean hasPrefix = hasText(prefix); + Set propertyNames = newLinkedHashSet(length(names)); + for (String name : names) { + String propertyName = hasPrefix ? prefix + name : name; + propertyNames.add(propertyName); + } + return propertyNames; + } + + protected void testConditionalOnPropertyEnabled(boolean enabled) { + Set propertyNames = getPropertyNames(); + Properties properties = getProperties(); + try { + for (String propertyName : propertyNames) { + properties.setProperty(propertyName, valueOf(enabled)); + } + testBean(enabled); + } finally { + for (String propertyName : propertyNames) { + properties.remove(propertyName); + } + } + } + + protected void testBean(boolean present) { + testInSpringContainer(context -> { + assertEquals(present, isBeanPresent(context, getClass())); + }, getClass()); + } +} \ No newline at end of file From 29641b9ec3ae9445cb5e39fa44ae4ce5fafd9a21 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 17:23:52 +0800 Subject: [PATCH 32/35] Remove unused matchIfMissing attribute from annotation Eliminated the matchIfMissing attribute and its related @AliasFor usage from the ConditionalOnFeaturesEnabled annotation, simplifying the annotation as the property is already set via @ConditionalOnProperty. --- .../client/condition/ConditionalOnFeaturesEnabled.java | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabled.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabled.java index fcfb14b..d7058b9 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabled.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/condition/ConditionalOnFeaturesEnabled.java @@ -21,7 +21,6 @@ import org.springframework.cloud.client.CommonsClientAutoConfiguration; import org.springframework.cloud.client.actuator.FeaturesEndpoint; import org.springframework.cloud.client.actuator.HasFeatures; -import org.springframework.core.annotation.AliasFor; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -49,13 +48,4 @@ @Documented @ConditionalOnProperty(name = FEATURES_ENABLED_PROPERTY_NAME, matchIfMissing = true) public @interface ConditionalOnFeaturesEnabled { - - /** - * Specify if the condition should match if the property is not set. Defaults to - * {@code true}. - * - * @return if the condition should match if the property is missing - */ - @AliasFor(annotation = ConditionalOnProperty.class, attribute = "matchIfMissing") - boolean matchIfMissing() default true; } From 3e9cf7cda003b3200f76bb8c88a88fa99a3ed275 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 18:57:39 +0800 Subject: [PATCH 33/35] Update ReactiveDiscoveryClientAdapter.java --- .../discovery/ReactiveDiscoveryClientAdapter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/ReactiveDiscoveryClientAdapter.java b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/ReactiveDiscoveryClientAdapter.java index 12f55e1..652ca76 100644 --- a/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/ReactiveDiscoveryClientAdapter.java +++ b/microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/discovery/ReactiveDiscoveryClientAdapter.java @@ -21,9 +21,13 @@ import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import java.util.List; +import static io.microsphere.lang.function.ThrowableSupplier.execute; +import static reactor.core.scheduler.Schedulers.isInNonBlockingThread; + /** * An adapter {@link DiscoveryClient} class based on {@link ReactiveDiscoveryClient} * @@ -67,6 +71,10 @@ public int getOrder() { } static List toList(Flux flux) { - return flux.collectList().block(); + Mono> mono = flux.collectList(); + if (isInNonBlockingThread()) { + return execute(() -> mono.toFuture().get()); + } + return mono.block(); } } \ No newline at end of file From 9c96e049105ed632bb2326edfb2ab866c845ddec Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 18:57:44 +0800 Subject: [PATCH 34/35] Add tests for ReactiveDiscoveryClientAdapter.toList Introduced test cases to verify the toList utility method in ReactiveDiscoveryClientAdapter using different schedulers. Ensures correct conversion of Flux to List under various scheduling scenarios. --- .../ReactiveDiscoveryClientAdapterTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/ReactiveDiscoveryClientAdapterTest.java b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/ReactiveDiscoveryClientAdapterTest.java index c6ae138..2f65a00 100644 --- a/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/ReactiveDiscoveryClientAdapterTest.java +++ b/microsphere-spring-cloud-commons/src/test/java/io/microsphere/spring/cloud/client/discovery/ReactiveDiscoveryClientAdapterTest.java @@ -26,15 +26,22 @@ import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient; import org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryClient; import org.springframework.cloud.client.discovery.simple.reactive.SimpleReactiveDiscoveryProperties; +import reactor.core.Disposable; +import reactor.core.publisher.Flux; +import reactor.core.scheduler.Scheduler; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.Callable; import static io.microsphere.collection.Lists.ofList; +import static io.microsphere.spring.cloud.client.discovery.ReactiveDiscoveryClientAdapter.toList; import static io.microsphere.spring.cloud.client.service.util.ServiceInstanceUtilsTest.createDefaultServiceInstance; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertSame; +import static reactor.core.scheduler.Schedulers.immediate; +import static reactor.core.scheduler.Schedulers.newSingle; /** * {@link ReactiveDiscoveryClientAdapter} @@ -97,4 +104,21 @@ void testProbe() { void testGetOrder() { assertEquals(this.client.getOrder(), this.adapter.getOrder()); } + + @Test + void testToList() throws Exception { + assertList(immediate(), "1,2,3"); + assertList(newSingle("test"), "1,2,3"); + } + + void assertList(Scheduler scheduler, T... values) throws Exception { + Flux flux = Flux.just(values); + Disposable disposable = scheduler.schedule(() -> { + List list = toList(flux); + assertEquals(ofList(values), list); + }); + if (disposable instanceof Callable) { + ((Callable) disposable).call(); + } + } } \ No newline at end of file From 22bbdc493f423a4a6b81b9bf7d75a7b947833612 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Fri, 31 Oct 2025 19:16:05 +0800 Subject: [PATCH 35/35] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8560990..1cd8cbd 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,8 @@ pom.xml: | **Branches** | **Purpose** | **Latest Version** | |--------------|--------------------------------------------------|--------------------| -| **0.2.x** | Compatible with Spring Cloud 2022.0.x - 2025.0.x | 0.2.3 | -| **0.1.x** | Compatible with Spring Cloud Hoxton - 2021.0.x | 0.1.3 | +| **0.2.x** | Compatible with Spring Cloud 2022.0.x - 2025.0.x | 0.2.4 | +| **0.1.x** | Compatible with Spring Cloud Hoxton - 2021.0.x | 0.1.4 | Then add the specific modules you need: