diff --git a/client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java b/client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java index c44935675..52b1ad886 100644 --- a/client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java +++ b/client/src/main/java/com/alibaba/nacos/client/config/impl/ServerListManager.java @@ -318,7 +318,7 @@ public class ServerListManager implements Closeable { if (StringUtils.isNotBlank(endpointUrl)) { this.serverAddrsStr = ""; } - this.endpoint = endpointUrl; + endpointTmp = endpointUrl; } this.endpoint = StringUtils.isNotBlank(endpointTmp) ? endpointTmp : ""; } diff --git a/client/src/test/java/com/alibaba/nacos/client/config/impl/ServerListManagerTest.java b/client/src/test/java/com/alibaba/nacos/client/config/impl/ServerListManagerTest.java index 8ef174f77..7915ede52 100644 --- a/client/src/test/java/com/alibaba/nacos/client/config/impl/ServerListManagerTest.java +++ b/client/src/test/java/com/alibaba/nacos/client/config/impl/ServerListManagerTest.java @@ -280,4 +280,17 @@ class ServerListManagerTest { assertFalse(serverListManager.getName().contains("endpointContextPath")); assertTrue(serverListManager.getName().contains("contextPath")); } + + @Test + void testUseEndpointParsingRule() throws NacosException { + System.setProperty("nacos.endpoint", "127.0.0.1"); + Properties properties = new Properties(); + properties.setProperty(PropertyKeyConst.ENDPOINT, "${nacos.endpoint}"); + properties.setProperty(PropertyKeyConst.IS_USE_ENDPOINT_PARSING_RULE, "true"); + properties.setProperty(PropertyKeyConst.ENDPOINT_PORT, "9090"); + final NacosClientProperties clientProperties = NacosClientProperties.PROTOTYPE.derive(properties); + ServerListManager serverListManager = new ServerListManager(clientProperties); + String addressServerUrl = serverListManager.addressServerUrl; + assertTrue(addressServerUrl.startsWith("http://127.0.0.1")); + } } \ No newline at end of file