From 4722609e8c86b57ec3aa8cdeb7b15db41da94324 Mon Sep 17 00:00:00 2001 From: kexianjun Date: Mon, 25 Feb 2019 16:08:18 +0800 Subject: [PATCH 1/4] fix 3555 --- .../org/apache/dubbo/rpc/cluster/support/ClusterUtils.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 8901e4cacec..37b3e719283 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 static URL mergeUrl(URL remoteUrl, Map localMap) { 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)) { From d11b0d396988e0d74700e02670b05c6e69c1abc2 Mon Sep 17 00:00:00 2001 From: kexianjun Date: Mon, 25 Feb 2019 19:23:51 +0800 Subject: [PATCH 2/4] fix UT failed --- .../java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 37b3e719283..384724c3c75 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,7 @@ public static URL mergeUrl(URL remoteUrl, Map localMap) { String remoteGroup = map.get(Constants.GROUP_KEY); String remoteRelease = map.get(Constants.RELEASE_KEY); map.putAll(localMap); - if (StringUtils.isNotEmpty(remoteGroup)) { + if (!map.containsKey(Constants.GROUP_KEY) || 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. From 79ab5f1de4203eedf15d8db3093a56004ed914af Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Thu, 7 Mar 2019 16:35:02 +0800 Subject: [PATCH 3/4] change check condition --- .../java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 384724c3c75..37b3e719283 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,7 @@ public static URL mergeUrl(URL remoteUrl, Map localMap) { String remoteGroup = map.get(Constants.GROUP_KEY); String remoteRelease = map.get(Constants.RELEASE_KEY); map.putAll(localMap); - if (!map.containsKey(Constants.GROUP_KEY) || StringUtils.isNotEmpty(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. From 524f893933dce1d5f495791b73067e2c42b1d983 Mon Sep 17 00:00:00 2001 From: "ken.lj" Date: Thu, 7 Mar 2019 20:07:13 +0800 Subject: [PATCH 4/4] Fix ut --- .../registry/dubbo/RegistryDirectoryTest.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) 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 c9e85e544ac..7d672097596 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 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 void testNotifyoverrideUrls_Nouse() { registryDirectory.notify(durls); List> invokers = registryDirectory.list(invocation); Assertions.assertEquals(2, invokers.size()); - Invoker a1Invoker = invokers.get(0); - Invoker b1Invoker = invokers.get(1); + Map> 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(); durls.add(URL.valueOf("override://0.0.0.0?timeout=1&connections=5")); @@ -688,13 +690,15 @@ public void testNotifyoverrideUrls_Nouse() { invokers = registryDirectory.list(invocation); Assertions.assertEquals(2, invokers.size()); - Invoker a2Invoker = invokers.get(0); - Invoker b2Invoker = invokers.get(1); + Map> 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"); } /**