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 2018/11/12 07:24:27 UTC

[incubator-dubbo] branch dev-metadata updated: record init status.

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

liujun pushed a commit to branch dev-metadata
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/dev-metadata by this push:
     new e2f664f  record init status.
e2f664f is described below

commit e2f664f003a74a476aacc6424e34f6303e143dbe
Author: ken.lj <ke...@gmail.com>
AuthorDate: Mon Nov 12 15:24:17 2018 +0800

    record init status.
---
 .../java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java
index 55a4d22..b88a12f 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java
@@ -41,6 +41,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
@@ -49,13 +50,15 @@ import java.util.stream.Collectors;
  */
 public class TagRouter extends AbstractRouter implements Comparable<Router>, ConfigurationListener {
     public static final String NAME = "TAG_ROUTER";
-    public static final int DEFAULT_PRIORITY = 100;
+    private static final int DEFAULT_PRIORITY = 100;
     private static final Logger logger = LoggerFactory.getLogger(TagRouter.class);
     private static final String TAGROUTERRULES_DATAID = ".tagrouters"; // acts
     private DynamicConfiguration configuration;
     private TagRouterRule tagRouterRule;
     private String application;
 
+    private AtomicBoolean isInited;
+
     public TagRouter(URL url) {
         this(ExtensionLoader.getExtensionLoader(DynamicConfigurationFactory.class).getAdaptiveExtension().getDynamicConfiguration(url), url);
     }
@@ -73,6 +76,9 @@ public class TagRouter extends AbstractRouter implements Comparable<Router>, Con
     }
 
     private void init() {
+        if (!isInited.compareAndSet(false, true)) {
+            return;
+        }
         if (StringUtils.isEmpty(application)) {
             logger.error("TagRouter must getConfig from or subscribe to a specific application, but the application in this TagRouter is not specified.");
         }