You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/08/16 02:24:35 UTC

[GitHub] [dubbo] pinxiong commented on a change in pull request #8508: Fix issue 8506

pinxiong commented on a change in pull request #8508:
URL: https://github.com/apache/dubbo/pull/8508#discussion_r689197765



##########
File path: dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleRegistry.java
##########
@@ -26,12 +26,7 @@
 import org.apache.dubbo.registry.RegistryFactory;
 import org.apache.dubbo.registry.support.AbstractRegistry;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;

Review comment:
       Remove the import*

##########
File path: dubbo-registry/dubbo-registry-multiple/src/main/java/org/apache/dubbo/registry/multiple/MultipleRegistry.java
##########
@@ -200,9 +195,27 @@ public void unsubscribe(URL url, NotifyListener listener) {
                 urls.addAll(tmpUrls);
             }
         }
+        urls = removeDuplicate(urls);
         return urls;
     }
 
+    protected static List<URL> removeDuplicate(List<URL> urls) {
+        Set<List<String>> set = new HashSet<>();
+        List<URL> dedupList = new ArrayList<>();
+        for (URL url : urls) {
+            List<String> tmp = new ArrayList<>();
+            tmp.add(url.getAddress());
+            tmp.add(url.getProtocol());
+            tmp.add(url.getParameter("group"));
+            tmp.add(url.getParameter("version"));
+            if (!set.contains(tmp)) {
+                set.add(tmp);
+                dedupList.add(url);
+            }

Review comment:
       It's not the best way to check if two URLs are equal, you can refer [URL#equals](https://github.com/apache/dubbo/blob/3.0/dubbo-common/src/main/java/org/apache/dubbo/common/URL.java#L1432)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org