fix NPE
pull/720/head
周立 6 years ago committed by GitHub
parent 14818051ee
commit c6e7b85137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,10 +36,13 @@ public class NacosRule extends AbstractLoadBalancerRule {
String name = loadBalancer.getName();
NamingService namingService = this.nacosDiscoveryProperties.namingServiceInstance();
List<Instance> instances = namingService.selectInstances(name, true);
List<Instance> instancesToChoose = instances;
if (CollectionUtils.isEmpty(instances)) {
log.warn("{}服务当前无任何实例", name);
return null;
}
List<Instance> instancesToChoose = instances;
if (StringUtils.isNotBlank(clusterName)) {
List<Instance> sameClusterInstances = instances.stream()
.filter(instance -> Objects.equals(clusterName, instance.getClusterName()))

Loading…
Cancel
Save