From f0553afa7b9b560a7ec5599323d890cd185b7f34 Mon Sep 17 00:00:00 2001 From: rushsky518 Date: Tue, 25 Jun 2019 16:10:47 +0800 Subject: [PATCH] =?UTF-8?q?#1344=20=E7=A7=BB=E5=8A=A8=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nacos/client/config/impl/ServerListManager.java | 8 +++++--- .../java/com/alibaba/nacos/client/identify/Constants.java | 4 ---- .../com/alibaba/nacos/client/naming/net/NamingProxy.java | 2 +- .../alibaba/nacos/client/naming/utils/UtilAndComs.java | 5 +++++ 4 files changed, 11 insertions(+), 8 deletions(-) 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 acba70c5a..d96d7378d 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 @@ -40,6 +40,8 @@ import java.util.concurrent.TimeUnit; public class ServerListManager { private static final Logger LOGGER = LogUtils.logger(ServerListManager.class); + private static final String HTTPS = "https://"; + private static final String HTTP = "http://"; public ServerListManager() { isFixed = false; @@ -120,14 +122,14 @@ public class ServerListManager { List serverAddrs = new ArrayList(); String[] serverAddrsArr = serverAddrsStr.split(","); for (String serverAddr: serverAddrsArr) { - if (serverAddr.startsWith(Constants.HTTPS) || serverAddr.startsWith(Constants.HTTP)) { + if (serverAddr.startsWith(HTTPS) || serverAddr.startsWith(HTTP)) { serverAddrs.add(serverAddr); } else { String[] serverAddrArr = serverAddr.split(":"); if (serverAddrArr.length == 1) { - serverAddrs.add(Constants.HTTP + serverAddrArr[0] + ":" + ParamUtil.getDefaultServerPort()); + serverAddrs.add(HTTP + serverAddrArr[0] + ":" + ParamUtil.getDefaultServerPort()); } else { - serverAddrs.add(Constants.HTTP + serverAddr); + serverAddrs.add(HTTP + serverAddr); } } } diff --git a/client/src/main/java/com/alibaba/nacos/client/identify/Constants.java b/client/src/main/java/com/alibaba/nacos/client/identify/Constants.java index 7792acad1..a94110720 100644 --- a/client/src/main/java/com/alibaba/nacos/client/identify/Constants.java +++ b/client/src/main/java/com/alibaba/nacos/client/identify/Constants.java @@ -49,8 +49,4 @@ public class Constants { public static final String NO_APP_NAME = ""; - public static final String HTTP = "http://"; - - public static final String HTTPS = "https://"; - } diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java index 78ad806ea..ed3a4928b 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/net/NamingProxy.java @@ -398,7 +398,7 @@ public class NamingProxy { List headers = builderHeaders(); String url; - if (curServer.startsWith(Constants.HTTPS) || curServer.startsWith(Constants.HTTP)) { + if (curServer.startsWith(UtilAndComs.HTTPS) || curServer.startsWith(UtilAndComs.HTTP)) { url = curServer + api; } else { if (!curServer.contains(UtilAndComs.SERVER_ADDR_IP_SPLITER)) { diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/utils/UtilAndComs.java b/client/src/main/java/com/alibaba/nacos/client/naming/utils/UtilAndComs.java index 9736560dc..617986afc 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/utils/UtilAndComs.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/utils/UtilAndComs.java @@ -55,4 +55,9 @@ public class UtilAndComs { public static final int DEFAULT_POLLING_THREAD_COUNT = Runtime.getRuntime() .availableProcessors() > 1 ? Runtime.getRuntime().availableProcessors() / 2 : 1; + + public static final String HTTP = "http://"; + + public static final String HTTPS = "https://"; + }