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/08/15 14:34:40 UTC

[dubbo] branch 3.0 updated: Fix typo and some optimizations (#8499)

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 f55a115  Fix typo and some optimizations (#8499)
f55a115 is described below

commit f55a11580e30a8ab97a8f9f1c9c275029666c355
Author: 灼华 <43...@users.noreply.github.com>
AuthorDate: Sun Aug 15 22:34:29 2021 +0800

    Fix typo and some optimizations (#8499)
---
 .../main/java/org/apache/dubbo/rpc/cluster/RouterChain.java   | 10 +++++-----
 .../dubbo/rpc/cluster/router/tag/TagDynamicStateRouter.java   | 11 +----------
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
index ef89b56..1b6b192 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/RouterChain.java
@@ -236,18 +236,18 @@ public class RouterChain<T> {
     /**
      * Cache the address list for each StateRouter.
      * @param router router
-     * @param orign The original address cache
+     * @param origin The original address cache
      * @param invokers The full address list
      * @param notify Whether the addresses in registry has changed.
      * @return
      */
-    private RouterCache poolRouter(StateRouter router, AddrCache<T> orign, List<Invoker<T>> invokers, boolean notify) {
+    private RouterCache poolRouter(StateRouter router, AddrCache<T> origin, List<Invoker<T>> invokers, boolean notify) {
         String routerName = router.getName();
         RouterCache routerCache;
-        if (isCacheMiss(orign, routerName) || router.shouldRePool() || notify) {
+        if (isCacheMiss(origin, routerName) || router.shouldRePool() || notify) {
             return router.pool(invokers);
         } else {
-            routerCache = orign.getCache().get(routerName);
+            routerCache = origin.getCache().get(routerName);
         }
         if (routerCache == null) {
             return new RouterCache();
@@ -293,8 +293,8 @@ public class RouterChain<T> {
 
         @Override
         public void run() {
-            loopPermit.release();
             buildCache(notify);
+            loopPermit.release();
         }
     }
 
diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagDynamicStateRouter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagDynamicStateRouter.java
index 231aa2c..347d1fd 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagDynamicStateRouter.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/tag/TagDynamicStateRouter.java
@@ -84,11 +84,6 @@ public class TagDynamicStateRouter extends AbstractStateRouter implements Config
     }
 
     @Override
-    public URL getUrl() {
-        return url;
-    }
-
-    @Override
     public <T> BitList<Invoker<T>> route(BitList<Invoker<T>> invokers, RouterCache<T> cache, URL url,
         Invocation invocation) throws RpcException {
 
@@ -154,11 +149,7 @@ public class TagDynamicStateRouter extends AbstractStateRouter implements Config
 
 
         if (tagRouterRuleCopy == null || !tagRouterRuleCopy.isValid() || !tagRouterRuleCopy.isEnabled()) {
-            BitList<Invoker<T>> noTagList = new BitList<>(invokers, true);
-
-            for (int index = 0; index < invokers.size(); index++) {
-                noTagList.addIndex(index);
-            }
+            BitList<Invoker<T>> noTagList = new BitList<>(invokers, false);
             addrPool.put(NO_TAG, noTagList);
             routerCache.setAddrPool(addrPool);
             return routerCache;