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

wangxin 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 bcc3e74  code promote: move constant field to Constants class (#2509)
bcc3e74 is described below

commit bcc3e741b3524be9a369e605d32bedd45f690220
Author: Jexy <[email protected]>
AuthorDate: Mon Sep 17 15:50:17 2018 +0800

    code promote: move constant field to Constants class (#2509)
---
 dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java     | 2 ++
 .../java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java   | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java 
b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
index 9506930..4d6e758 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java
@@ -362,6 +362,8 @@ public class Constants {
 
     public final static String PATH_SEPARATOR = "/";
 
+    public final static String PROTOCOL_SEPARATOR = "://";
+
     public static final String REGISTRY_SEPARATOR = "|";
 
     public static final Pattern REGISTRY_SPLIT_PATTERN = Pattern
diff --git 
a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
 
b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
index 86465b6..43426c7 100644
--- 
a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
+++ 
b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperRegistry.java
@@ -278,7 +278,7 @@ public class ZookeeperRegistry extends FailbackRegistry {
         if (providers != null && !providers.isEmpty()) {
             for (String provider : providers) {
                 provider = URL.decode(provider);
-                if (provider.contains("://")) {
+                if (provider.contains(Constants.PROTOCOL_SEPARATOR)) {
                     URL url = URL.valueOf(provider);
                     if (UrlUtils.isMatch(consumer, url)) {
                         urls.add(url);
@@ -292,7 +292,7 @@ public class ZookeeperRegistry extends FailbackRegistry {
     private List<URL> toUrlsWithEmpty(URL consumer, String path, List<String> 
providers) {
         List<URL> urls = toUrlsWithoutEmpty(consumer, providers);
         if (urls == null || urls.isEmpty()) {
-            int i = path.lastIndexOf('/');
+            int i = path.lastIndexOf(Constants.PATH_SEPARATOR);
             String category = i < 0 ? path : path.substring(i + 1);
             URL empty = 
consumer.setProtocol(Constants.EMPTY_PROTOCOL).addParameter(Constants.CATEGORY_KEY,
 category);
             urls.add(empty);

Reply via email to