Skip to content

Commit

Permalink
[ISSUE alibaba#12219] 修复nacos-client中config的ServerListManager解析endpoi…
Browse files Browse the repository at this point in the history
…nt失败问题 (alibaba#12220)

* [ISSUE alibaba#12219] 修复nacos-client中config的ServerListManager解析endpoint失败问题

* [ISSUE alibaba#12219] 修复nacos-client中config的ServerListManager解析endpoint失败问题
  • Loading branch information
misakacoder authored Jul 1, 2024
1 parent 92a3d17 commit 9716243
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private void initEndpoint(final NacosClientProperties properties) {
if (StringUtils.isNotBlank(endpointUrl)) {
this.serverAddrsStr = "";
}
this.endpoint = endpointUrl;
endpointTmp = endpointUrl;
}
this.endpoint = StringUtils.isNotBlank(endpointTmp) ? endpointTmp : "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,4 +280,17 @@ void testWithoutEndpointContextPath() throws NacosException {
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"));
}
}

0 comments on commit 9716243

Please sign in to comment.