diff --git a/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java b/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java index 7bc7497a5..b63ca6a96 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/cluster/ServerListManager.java @@ -74,7 +74,7 @@ public class ServerListManager { GlobalExecutor.registerServerStatusReporter(new ServerStatusReporter(), 5000); } - public List refreshServerList() { + private List refreshServerList() { List result = new ArrayList<>(); @@ -111,12 +111,12 @@ public class ServerListManager { String ip; int port; - if (serverList.get(0).contains(UtilsAndCommons.IP_PORT_SPLITER)) { - - ip = serverList.get(i).split(UtilsAndCommons.IP_PORT_SPLITER)[0]; - port = Integer.parseInt(serverList.get(i).split(UtilsAndCommons.IP_PORT_SPLITER)[1]); + String server = serverList.get(i); + if (server.contains(UtilsAndCommons.IP_PORT_SPLITER)) { + ip = server.split(UtilsAndCommons.IP_PORT_SPLITER)[0]; + port = Integer.parseInt(server.split(UtilsAndCommons.IP_PORT_SPLITER)[1]); } else { - ip = serverList.get(i); + ip = server; port = RunningConfig.getServerPort(); }