Skip to content

Commit

Permalink
[ISSUE alibaba#8372] Fix https connection (alibaba#8380)
Browse files Browse the repository at this point in the history
* Fix alibaba#8372

* add unit test and remove set serverAddrsStr null

* restore judgement and UT

* add UT

* split UT
  • Loading branch information
Oliverwqcwrw authored May 18, 2022
1 parent 3a37290 commit dbcdbb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public ServerListManager(Properties properties) throws NacosException {
StringTokenizer serverAddrsTokens = new StringTokenizer(this.serverAddrsStr, ",;");
while (serverAddrsTokens.hasMoreTokens()) {
String serverAddr = serverAddrsTokens.nextToken().trim();
if (serverAddr.startsWith(HTTP_PREFIX) || serverAddr.startsWith(HTTP_PREFIX)) {
if (serverAddr.startsWith(HTTP_PREFIX) || serverAddr.startsWith(HTTPS_PREFIX)) {
serverAddrs.add(serverAddr);
} else {
String[] serverAddrArr = InternetAddressUtil.splitIPPortStr(serverAddr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ public void testGetter() throws NacosException {
final ServerListManager mgr2 = new ServerListManager(properties);
Assert.assertEquals("aaa", mgr2.getContentPath());
}

// Test https
{
Properties properties = new Properties();
properties.put(PropertyKeyConst.CONTEXT_PATH, "aaa");
properties.put(PropertyKeyConst.SERVER_ADDR, "https://1.1.1.1:8848");
final ServerListManager mgr2 = new ServerListManager(properties);
Assert.assertEquals("aaa", mgr2.getContentPath());
Assert.assertEquals("[https://1.1.1.1:8848]", mgr2.getServerUrls().toString());
}

{
Properties properties2 = new Properties();
Expand Down

0 comments on commit dbcdbb7

Please sign in to comment.