mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
fix NPE
fix NPE
This commit is contained in:
parent
14818051ee
commit
c6e7b85137
@ -36,10 +36,13 @@ public class NacosRule extends AbstractLoadBalancerRule {
|
|||||||
String name = loadBalancer.getName();
|
String name = loadBalancer.getName();
|
||||||
|
|
||||||
NamingService namingService = this.nacosDiscoveryProperties.namingServiceInstance();
|
NamingService namingService = this.nacosDiscoveryProperties.namingServiceInstance();
|
||||||
|
|
||||||
List<Instance> instances = namingService.selectInstances(name, true);
|
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)) {
|
if (StringUtils.isNotBlank(clusterName)) {
|
||||||
List<Instance> sameClusterInstances = instances.stream()
|
List<Instance> sameClusterInstances = instances.stream()
|
||||||
.filter(instance -> Objects.equals(clusterName, instance.getClusterName()))
|
.filter(instance -> Objects.equals(clusterName, instance.getClusterName()))
|
||||||
@ -63,4 +66,4 @@ public class NacosRule extends AbstractLoadBalancerRule {
|
|||||||
@Override
|
@Override
|
||||||
public void initWithNiwsConfig(IClientConfig iClientConfig) {
|
public void initWithNiwsConfig(IClientConfig iClientConfig) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user