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 e40127984..4c99c42c3 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 @@ -108,7 +108,7 @@ public class NamingProxy implements Closeable { private Properties properties; private ScheduledExecutorService executorService; - + private int maxRetry; public NamingProxy(String namespaceId, String endpoint, String serverList, Properties properties) { @@ -119,8 +119,8 @@ public class NamingProxy implements Closeable { this.namespaceId = namespaceId; this.endpoint = endpoint; this.maxRetry = ConvertUtils.toInt(properties.getProperty(PropertyKeyConst.NAMING_REQUEST_DOMAIN_RETRY_COUNT, - String.valueOf(UtilAndComs.REQUEST_DOMAIN_RETRY_COUNT))); - + String.valueOf(UtilAndComs.REQUEST_DOMAIN_RETRY_COUNT))); + if (StringUtils.isNotEmpty(serverList)) { this.serverList = Arrays.asList(serverList.split(",")); if (this.serverList.size() == 1) { @@ -514,12 +514,12 @@ public class NamingProxy implements Closeable { params.put(CommonParams.NAMESPACE_ID, getNamespaceId()); - if (CollectionUtils.isEmpty(servers) && StringUtils.isEmpty(nacosDomain)) { + if (CollectionUtils.isEmpty(servers) && StringUtils.isBlank(nacosDomain)) { throw new NacosException(NacosException.INVALID_PARAM, "no server available"); } NacosException exception = new NacosException(); - + if (StringUtils.isNotBlank(nacosDomain)) { for (int i = 0; i < maxRetry; i++) { try { @@ -531,10 +531,7 @@ public class NamingProxy implements Closeable { } } } - } - - if (servers != null && !servers.isEmpty()) { - + } else { Random random = new Random(System.currentTimeMillis()); int index = random.nextInt(servers.size());