You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by me...@apache.org on 2019/09/06 09:13:44 UTC

[dubbo] branch master updated: follow up for pr#4974, optimize imports and switch to use dubbo's stringutils (#5012)

This is an automated email from the ASF dual-hosted git repository.

mercyblitz 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 1cb034c  follow up for pr#4974, optimize imports and switch to use dubbo's stringutils (#5012)
1cb034c is described below

commit 1cb034cd0b0c8e79b1ecb2595dd283b0d4bd1a9f
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Fri Sep 6 17:13:17 2019 +0800

    follow up for pr#4974, optimize imports and switch to use dubbo's stringutils (#5012)
---
 .../apache/dubbo/registry/nacos/NacosRegistry.java | 56 +++++++++++-----------
 .../dubbo/registry/nacos/NacosServiceName.java     | 20 ++++----
 2 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
index 5c90780..3244d6a 100644
--- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
+++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosRegistry.java
@@ -16,20 +16,15 @@
  */
 package org.apache.dubbo.registry.nacos;
 
-import static java.util.Collections.singleton;
-import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
-import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
-import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
-import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
-import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
-import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
-import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
-import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY;
-import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY;
-import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDERS_CATEGORY;
-import static org.apache.dubbo.common.constants.RegistryConstants.ROUTERS_CATEGORY;
-import static org.apache.dubbo.registry.Constants.ADMIN_PROTOCOL;
-import static org.apache.dubbo.registry.nacos.NacosServiceName.valueOf;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.StringUtils;
+import org.apache.dubbo.common.utils.UrlUtils;
+import org.apache.dubbo.registry.NotifyListener;
+import org.apache.dubbo.registry.Registry;
+import org.apache.dubbo.registry.support.FailbackRegistry;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -48,14 +43,6 @@ import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.logger.Logger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.common.utils.UrlUtils;
-import org.apache.dubbo.registry.NotifyListener;
-import org.apache.dubbo.registry.Registry;
-import org.apache.dubbo.registry.support.FailbackRegistry;
-
 import com.alibaba.nacos.api.exception.NacosException;
 import com.alibaba.nacos.api.naming.NamingService;
 import com.alibaba.nacos.api.naming.listener.EventListener;
@@ -63,6 +50,21 @@ import com.alibaba.nacos.api.naming.listener.NamingEvent;
 import com.alibaba.nacos.api.naming.pojo.Instance;
 import com.alibaba.nacos.api.naming.pojo.ListView;
 
+import static java.util.Collections.singleton;
+import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
+import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
+import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
+import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
+import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
+import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
+import static org.apache.dubbo.common.constants.RegistryConstants.CONFIGURATORS_CATEGORY;
+import static org.apache.dubbo.common.constants.RegistryConstants.CONSUMERS_CATEGORY;
+import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY;
+import static org.apache.dubbo.common.constants.RegistryConstants.PROVIDERS_CATEGORY;
+import static org.apache.dubbo.common.constants.RegistryConstants.ROUTERS_CATEGORY;
+import static org.apache.dubbo.registry.Constants.ADMIN_PROTOCOL;
+import static org.apache.dubbo.registry.nacos.NacosServiceName.valueOf;
+
 /**
  * Nacos {@link Registry}
  *
@@ -335,20 +337,20 @@ public class NacosRegistry extends FailbackRegistry {
             }
 
             String serviceInterface = segments[SERVICE_INTERFACE_INDEX];
+            // no match service interface
             if (!WILDCARD.equals(targetServiceInterface) &&
-                    !targetServiceInterface.equals(serviceInterface)) { // no match service interface
+                    !StringUtils.isEquals(targetServiceInterface, serviceInterface)) {
                 return false;
             }
 
+            // no match service version
             String version = segments[SERVICE_VERSION_INDEX];
-            if (!WILDCARD.equals(targetVersion) &&
-                    !targetVersion.equals(version)) { // no match service version
+            if (!WILDCARD.equals(targetVersion) && !StringUtils.isEquals(targetVersion, version)) {
                 return false;
             }
 
             String group = segments[SERVICE_GROUP_INDEX];
-            return group == null || WILDCARD.equals(targetGroup)
-                    || targetGroup.equals(group);
+            return group == null || WILDCARD.equals(targetGroup) || StringUtils.isEquals(targetGroup, group);
         });
     }
 
diff --git a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceName.java b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceName.java
index bb609ca..27c45ee 100644
--- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceName.java
+++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceName.java
@@ -16,6 +16,12 @@
  */
 package org.apache.dubbo.registry.nacos;
 
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.utils.StringUtils;
+
+import java.util.Arrays;
+import java.util.Objects;
+
 import static org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.INTERFACE_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
@@ -23,11 +29,6 @@ import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY;
 import static org.apache.dubbo.common.constants.RegistryConstants.DEFAULT_CATEGORY;
 import static org.apache.dubbo.common.utils.StringUtils.isBlank;
 
-import java.util.Arrays;
-import java.util.Objects;
-
-import org.apache.dubbo.common.URL;
-
 /**
  * The service name of Nacos
  *
@@ -107,12 +108,12 @@ public class NacosServiceName {
         }
 
         // Not match comparison
-        if (!this.category.equals(concreteServiceName.category)
+        if (!StringUtils.isEquals(this.category, concreteServiceName.category)
                 && !matchRange(this.category, concreteServiceName.category)) {
             return false;
         }
 
-        if (!this.serviceInterface.equals(concreteServiceName.serviceInterface)) {
+        if (!StringUtils.isEquals(this.serviceInterface, concreteServiceName.serviceInterface)) {
             return false;
         }
 
@@ -126,12 +127,13 @@ public class NacosServiceName {
         }
 
         // range condition
-        if (!this.version.equals(concreteServiceName.version)
+        if (!StringUtils.isEquals(this.version, concreteServiceName.version)
                 && !matchRange(this.version, concreteServiceName.version)) {
             return false;
         }
 
-        if (!this.group.equals(concreteServiceName.group) && !matchRange(this.group, concreteServiceName.group)) {
+        if (!StringUtils.isEquals(this.group, concreteServiceName.group) &&
+                !matchRange(this.group, concreteServiceName.group)) {
             return false;
         }