Skip to content

Commit effefd4

Browse files
committed
remove interface key in contextFilter
1 parent 47f4a44 commit effefd4

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/AbstractClusterInvoker.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,6 @@ public Result invoke(final Invocation invocation) throws RpcException {
234234
Map<String, String> contextAttachments = RpcContext.getContext().getAttachments();
235235
if (contextAttachments != null && contextAttachments.size() != 0) {
236236
((RpcInvocation) invocation).addAttachments(contextAttachments);
237-
// We need to remove the interface because the interface here may come from last invoke.
238-
//
239-
// See https://github.com/apache/incubator-dubbo/issues/2981
240-
if (invocation.getAttachments() != null) {
241-
invocation.getAttachments().remove(Constants.INTERFACE_KEY);
242-
}
243237
}
244238

245239
List<Invoker<T>> invokers = list(invocation);

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public class ContextFilter implements Filter {
4242
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
4343
Map<String, String> attachments = invocation.getAttachments();
4444
if (attachments != null) {
45-
attachments = new HashMap<String, String>(attachments);
45+
attachments = new HashMap<>(attachments);
4646
attachments.remove(Constants.PATH_KEY);
47+
attachments.remove(Constants.INTERFACE_KEY);
4748
attachments.remove(Constants.GROUP_KEY);
4849
attachments.remove(Constants.VERSION_KEY);
4950
attachments.remove(Constants.DUBBO_VERSION_KEY);

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/protocol/AbstractInvoker.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ public Result invoke(Invocation inv) throws RpcException {
134134
}
135135
RpcInvocation invocation = (RpcInvocation) inv;
136136
invocation.setInvoker(this);
137-
137+
if (attachment != null && attachment.size() > 0) {
138+
invocation.addAttachmentsIfAbsent(attachment);
139+
}
138140
Map<String, String> contextAttachments = RpcContext.getContext().getAttachments();
139141
if (contextAttachments != null && contextAttachments.size() != 0) {
140142
/**
@@ -150,15 +152,6 @@ public Result invoke(Invocation inv) throws RpcException {
150152
}
151153
RpcUtils.attachInvocationIdIfAsync(getUrl(), invocation);
152154

153-
// If we have attachment, override the attachment to ensure that the last invoke's attach does not affect this call.
154-
// In most cases, attachments contains interface, timeout, group, and token.
155-
// These info should be override in each invoke.
156-
//
157-
// See https://github.com/apache/incubator-dubbo/issues/2981
158-
if (attachment != null && attachment.size() > 0) {
159-
invocation.addAttachments(attachment);
160-
}
161-
162155
try {
163156
return doInvoke(invocation);
164157
} catch (InvocationTargetException e) { // biz exception

0 commit comments

Comments
 (0)