You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by so...@apache.org on 2019/12/22 10:29:15 UTC
[dubbo] branch master updated: Simplify collect body by using a
method (#5523)
This is an automated email from the ASF dual-hosted git repository.
songkun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 9e9517d Simplify collect body by using a method (#5523)
9e9517d is described below
commit 9e9517dc2fb2892a256b8e2a0eaaadb9164b8b61
Author: Kun Song <so...@gmail.com>
AuthorDate: Sun Dec 22 18:28:38 2019 +0800
Simplify collect body by using a method (#5523)
---
.../registry/integration/RegistryDirectory.java | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
index 939ec54..4cb9d4d 100644
--- a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
+++ b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryDirectory.java
@@ -213,16 +213,7 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
.filter(Objects::nonNull)
.filter(this::isValidCategory)
.filter(this::isNotCompatibleFor26x)
- .collect(Collectors.groupingBy(url -> {
- if (UrlUtils.isConfigurator(url)) {
- return CONFIGURATORS_CATEGORY;
- } else if (UrlUtils.isRoute(url)) {
- return ROUTERS_CATEGORY;
- } else if (UrlUtils.isProvider(url)) {
- return PROVIDERS_CATEGORY;
- }
- return "";
- }));
+ .collect(Collectors.groupingBy(this::judgeCategory));
List<URL> configuratorURLs = categoryUrls.getOrDefault(CONFIGURATORS_CATEGORY, Collections.emptyList());
this.configurators = Configurator.toConfigurators(configuratorURLs).orElse(this.configurators);
@@ -245,6 +236,17 @@ public class RegistryDirectory<T> extends AbstractDirectory<T> implements Notify
refreshOverrideAndInvoker(providerURLs);
}
+ private String judgeCategory(URL url) {
+ if (UrlUtils.isConfigurator(url)) {
+ return CONFIGURATORS_CATEGORY;
+ } else if (UrlUtils.isRoute(url)) {
+ return ROUTERS_CATEGORY;
+ } else if (UrlUtils.isProvider(url)) {
+ return PROVIDERS_CATEGORY;
+ }
+ return "";
+ }
+
private void refreshOverrideAndInvoker(List<URL> urls) {
// mock zookeeper://xxx?mock=return null
overrideDirectoryUrl();