Skip to content

Commit

Permalink
Merge pull request #3558, check if remoteGroup is empty or not.
Browse files Browse the repository at this point in the history
Fixes  #3555.
  • Loading branch information
kexianjun authored and chickenlj committed Mar 8, 2019
1 parent b8827f9 commit 42646d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public static URL mergeUrl(URL remoteUrl, Map<String, String> 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -677,8 +678,9 @@ public void testNotifyoverrideUrls_Nouse() {
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"));
Expand All @@ -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<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");
}

/**
Expand Down

0 comments on commit 42646d7

Please sign in to comment.