You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2019/03/08 06:50:55 UTC

[incubator-dubbo] branch master updated: Merge pull request #3558, check if remoteGroup is empty or not.

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

liujun 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 42646d7  Merge pull request #3558, check if remoteGroup is empty or not.
42646d7 is described below

commit 42646d7f36dd0394a10b77e0175be430067f943f
Author: kexianjun <ke...@hotmail.com>
AuthorDate: Fri Mar 8 14:50:46 2019 +0800

    Merge pull request #3558, check if remoteGroup is empty or not.
    
    Fixes  #3555.
---
 .../apache/dubbo/rpc/cluster/support/ClusterUtils.java   |  4 +++-
 .../dubbo/registry/dubbo/RegistryDirectoryTest.java      | 16 ++++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java
index 8901e4c..37b3e71 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java
@@ -84,7 +84,9 @@ public class ClusterUtils {
             String remoteGroup = map.get(Constants.GROUP_KEY);
             String remoteRelease = map.get(Constants.RELEASE_KEY);
             map.putAll(localMap);
-            map.put(Constants.GROUP_KEY, remoteGroup);
+            if (StringUtils.isNotEmpty(remoteGroup)) {
+                map.put(Constants.GROUP_KEY, remoteGroup);
+            }
             // we should always keep the Provider RELEASE_KEY not overrode by the the value on Consumer side.
             map.remove(Constants.RELEASE_KEY);
             if (StringUtils.isNotEmpty(remoteRelease)) {
diff --git a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java
index c9e85e5..7d67209 100644
--- a/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java
+++ b/dubbo-registry/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java
@@ -44,6 +44,7 @@ import org.mockito.Mockito;
 import javax.script.ScriptEngineManager;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
@@ -677,8 +678,9 @@ public class RegistryDirectoryTest {
         registryDirectory.notify(durls);
         List<Invoker<?>> invokers = registryDirectory.list(invocation);
         Assertions.assertEquals(2, invokers.size());
-        Invoker<?> a1Invoker = invokers.get(0);
-        Invoker<?> b1Invoker = invokers.get(1);
+        Map<String, Invoker<?>> map = new HashMap<>();
+        map.put(invokers.get(0).getUrl().getAddress(), invokers.get(0));
+        map.put(invokers.get(1).getUrl().getAddress(), invokers.get(1));
 
         durls = new ArrayList<URL>();
         durls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5"));
@@ -688,13 +690,15 @@ public class RegistryDirectoryTest {
         invokers = registryDirectory.list(invocation);
         Assertions.assertEquals(2, invokers.size());
 
-        Invoker<?> a2Invoker = invokers.get(0);
-        Invoker<?> b2Invoker = invokers.get(1);
+        Map<String, Invoker<?>> map2 = new HashMap<>();
+        map2.put(invokers.get(0).getUrl().getAddress(), invokers.get(0));
+        map2.put(invokers.get(1).getUrl().getAddress(), invokers.get(1));
+
         //The parameters are different and must be rereferenced.
-        Assertions.assertTrue(a1Invoker == a2Invoker, "object should not same");
+        Assertions.assertFalse(map.get(SERVICEURL.getAddress()) == map2.get(SERVICEURL.getAddress()), "object should not same");
 
         //The parameters can not be rereferenced
-        Assertions.assertFalse(b1Invoker == b2Invoker, "object should same");
+        Assertions.assertTrue(map.get(SERVICEURL2.getAddress()) == map2.get(SERVICEURL2.getAddress()), "object should not same");
     }
 
     /**