You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by hu...@apache.org on 2019/04/26 06:01:28 UTC
[incubator-dubbo] branch master updated: Defensive check to solve
issue #3923 (#3931)
This is an automated email from the ASF dual-hosted git repository.
huxing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 793bf82 Defensive check to solve issue #3923 (#3931)
793bf82 is described below
commit 793bf8244411c33b675e08f1499122bc82654d44
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Fri Apr 26 14:01:23 2019 +0800
Defensive check to solve issue #3923 (#3931)
---
.../main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java
index 72f7ff4..f9a30f3 100644
--- a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java
+++ b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java
@@ -37,6 +37,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
@@ -200,7 +201,11 @@ public class ConsulRegistry extends FailbackRegistry {
private List<URL> convert(List<HealthService> services) {
return services.stream()
- .map(s -> s.getService().getMeta().get(URL_META_KEY))
+ .map(HealthService::getService)
+ .filter(Objects::nonNull)
+ .map(HealthService.Service::getMeta)
+ .filter(m -> m != null && m.containsKey(URL_META_KEY))
+ .map(m -> m.get(URL_META_KEY))
.map(URL::valueOf)
.collect(Collectors.toList());
}