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/09/20 11:02:34 UTC
[dubbo] branch 3.0 updated: Fix RpcContext duplicated override
(#8842)
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 f8e4bd4 Fix RpcContext duplicated override (#8842)
f8e4bd4 is described below
commit f8e4bd4787bd3caecbb8238e18202b8efb825a3c
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Mon Sep 20 19:01:47 2021 +0800
Fix RpcContext duplicated override (#8842)
* Fix RpcContext duplicated override
* Fix import
---
.../cluster/filter/support/ConsumerContextFilter.java | 6 +++---
.../apache/dubbo/rpc/protocol/AbstractInvoker.java | 19 -------------------
2 files changed, 3 insertions(+), 22 deletions(-)
diff --git a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java
index c74b9a4..1b803de 100644
--- a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java
+++ b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/filter/support/ConsumerContextFilter.java
@@ -47,7 +47,7 @@ import static org.apache.dubbo.common.constants.CommonConstants.TIME_COUNTDOWN_K
* @see Filter
* @see RpcContext
*/
-@Activate(group = CONSUMER, order = -10000)
+@Activate(group = CONSUMER, order = Integer.MIN_VALUE)
public class ConsumerContextFilter implements ClusterFilter, ClusterFilter.Listener {
private ApplicationModel applicationModel;
@@ -74,11 +74,11 @@ public class ConsumerContextFilter implements ClusterFilter, ClusterFilter.Liste
for (String supportedSelector : supportedSelectors) {
Map<String, Object> selected = selectorExtensionLoader.getExtension(supportedSelector).select();
if (CollectionUtils.isNotEmptyMap(selected)) {
- ((RpcInvocation) invocation).addObjectAttachmentsIfAbsent(selected);
+ ((RpcInvocation) invocation).addObjectAttachments(selected);
}
}
} else {
- ((RpcInvocation) invocation).addObjectAttachmentsIfAbsent(RpcContext.getServerAttachment().getObjectAttachments());
+ ((RpcInvocation) invocation).addObjectAttachments(RpcContext.getServerAttachment().getObjectAttachments());
}
Map<String, Object> contextAttachments = RpcContext.getClientAttachment().getObjectAttachments();
diff --git a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java
index 13ff94b..1723595 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java
@@ -19,7 +19,6 @@ package org.apache.dubbo.rpc.protocol;
import org.apache.dubbo.common.Node;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.Version;
-import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.threadpool.ThreadlessExecutor;
@@ -34,7 +33,6 @@ import org.apache.dubbo.rpc.AsyncRpcResult;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.InvokeMode;
import org.apache.dubbo.rpc.Invoker;
-import org.apache.dubbo.rpc.PenetrateAttachmentSelector;
import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.rpc.RpcException;
@@ -46,7 +44,6 @@ import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
@@ -210,22 +207,6 @@ public abstract class AbstractInvoker<T> implements Invoker<T> {
if (CollectionUtils.isNotEmptyMap(clientContextAttachments)) {
invocation.addObjectAttachmentsIfAbsent(clientContextAttachments);
}
-
- // server context attachment
- ExtensionLoader<PenetrateAttachmentSelector> selectorExtensionLoader = invocation.getModuleModel().getExtensionLoader(PenetrateAttachmentSelector.class);
- Set<String> supportedSelectors = selectorExtensionLoader.getSupportedExtensions();
- if (CollectionUtils.isNotEmpty(supportedSelectors)) {
- // custom context attachment
- for (String supportedSelector : supportedSelectors) {
- Map<String, Object> selected = selectorExtensionLoader.getExtension(supportedSelector).select();
- if (CollectionUtils.isNotEmptyMap(selected)) {
- invocation.addObjectAttachmentsIfAbsent(selected);
- }
- }
- } else {
- Map<String, Object> serverContextAttachments = RpcContext.getServerAttachment().getObjectAttachments();
- invocation.addObjectAttachmentsIfAbsent(serverContextAttachments);
- }
}
private AsyncRpcResult doInvokeAndReturn(RpcInvocation invocation) {