You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/06/28 11:22:07 UTC

[dubbo] branch 3.0 updated: Optimize MeshRuleAddressListenerInterceptor code (#8152)

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

albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 441c453  Optimize MeshRuleAddressListenerInterceptor code (#8152)
441c453 is described below

commit 441c4531879c8c06d03d1331e630063d3a41b2e4
Author: Xiong, Pin <pi...@foxmail.com>
AuthorDate: Mon Jun 28 06:21:48 2021 -0500

    Optimize MeshRuleAddressListenerInterceptor code (#8152)
---
 .../router/mesh/route/MeshRuleAddressListenerInterceptor.java     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/route/MeshRuleAddressListenerInterceptor.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/route/MeshRuleAddressListenerInterceptor.java
index e107456..4686190 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/route/MeshRuleAddressListenerInterceptor.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/mesh/route/MeshRuleAddressListenerInterceptor.java
@@ -19,17 +19,17 @@ package org.apache.dubbo.rpc.cluster.router.mesh.route;
 
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.extension.Activate;
+import org.apache.dubbo.common.utils.ConcurrentHashSet;
 import org.apache.dubbo.registry.AddressListener;
 import org.apache.dubbo.rpc.cluster.Directory;
 
 import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.Set;
 
 @Activate(order = 670)
 public class MeshRuleAddressListenerInterceptor implements AddressListener {
 
-    private static final Object MARK = new Object();
-    private static final ConcurrentHashMap<String, Object> APP_MAP = new ConcurrentHashMap<>();
+    private static final Set<String> APP_SET = new ConcurrentHashSet<>();
 
     @Override
     public List<URL> notify(List<URL> addresses, URL consumerUrl, Directory registryDirectory) {
@@ -39,7 +39,7 @@ public class MeshRuleAddressListenerInterceptor implements AddressListener {
 
                 String app = url.getRemoteApplication();
                 if (app != null && !app.isEmpty()) {
-                    if (APP_MAP.putIfAbsent(app, MARK) == null) {
+                    if (APP_SET.add(app)) {
                         MeshRuleManager.subscribeAppRule(app);
                     }
                 }