Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private void initEndpoint(final NacosClientProperties properties) {
if (StringUtils.isNotBlank(endpointUrl)) {
this.serverAddrsStr = "";
}
this.endpoint = endpointUrl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是这行改成endpointTmp=endpointUrl 即可

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样改也可以

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那麻烦改一下

endpointTmp = endpointUrl;
}
this.endpoint = StringUtils.isNotBlank(endpointTmp) ? endpointTmp : "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,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"));
}
}
Loading