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/09/09 09:09:25 UTC
[incubator-dubbo] branch dev-metadata updated: Fix small bugs and
add comments
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 4ef7f28 Fix small bugs and add comments
4ef7f28 is described below
commit 4ef7f28d367d8f2066871575ab6d2d985f8f8928
Author: ken.lj <ke...@gmail.com>
AuthorDate: Sun Sep 9 17:09:13 2018 +0800
Fix small bugs and add comments
---
.../java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java | 6 +++---
.../java/org/apache/dubbo/rpc/cluster/router/tag/TagRouter.java | 3 ++-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java
index 7a497a3..5ce835b 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/router/InvokerTreeCache.java
@@ -31,7 +31,7 @@ import java.util.List;
*/
public class InvokerTreeCache<T> {
- TreeNode<T> tree;
+ private TreeNode<T> tree;
public TreeNode buildTree() {
tree = new TreeNode<>();
@@ -43,7 +43,7 @@ public class InvokerTreeCache<T> {
public List<Invoker<T>> getInvokers(TreeNode<T> node, URL url, Invocation invocation) {
// We have reached the leaf node.
- if (node.getChildren() == null || node.getChildren().size() == 0) {
+ if (node.isLeaf()) {
return node.getInvokers();
}
@@ -102,7 +102,7 @@ public class InvokerTreeCache<T> {
String forceKey = "force." + failoverNode.getConditionKey();
if (Boolean.valueOf(invocation.getAttachment(forceKey, url.getParameter(forceKey, "false")))) {
/**
- * This may mistakely return empty list for runtime routers
+ * This may mistakenly return empty list for runtime routers
* see {@link org.apache.dubbo.rpc.cluster.router.tag.TagRouter.getKey()} for the workaround.
*/
return Collections.emptyList();
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 4638815..9d14d96 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
@@ -132,7 +132,8 @@ public class TagRouter extends AbstractRouter implements Comparable<Router>, Con
// dynamic tag group doesn't have any item about the requested app OR it's null after filtered by dynamic tag group but force=false.
// check static tag
result = filterInvoker(invokers, invoker -> tag.equals(invoker.getUrl().getParameter(Constants.TAG_KEY)));
- if (CollectionUtils.isNotEmpty(result) || url.getParameter(Constants.FORCE_USE_TAG, true)) {
+ // If there's no tagged providers that can match the value in this tag. force.tag is set by default to true, which means it will not invoker any providers without a tag unless it's explicitly allowed.
+ if (CollectionUtils.isNotEmpty(result) || Boolean.valueOf(invocation.getAttachment(Constants.FORCE_USE_TAG, url.getParameter(Constants.FORCE_USE_TAG, "false")))) {
return result;
}
// FAILOVER: return all Providers without any tags.