120 Star 979 Fork 230

GVPdromara / TLog

 / 详情

Dubbo 2.7.7版本Invocation的attachments会被RpcContext的attachments覆盖

Done
Opened this issue  
2020-10-26 16:11

Dubbo 2.7.7版本Invocation的attachments会被RpcContext的attachments覆盖
ServiceA->ServiceB->ServiceC
SericeC由于attachments被覆盖 所以导致拿到的是ServiceA的数据
duboo2.7.7

public abstract class AbstractInvoker<T> implements Invoker<T> { 
public Result invoke(Invocation inv) throws RpcException {
        //省略代码
        Map<String, Object> contextAttachments = RpcContext.getContext().getObjectAttachments();
        if (CollectionUtils.isNotEmptyMap(contextAttachments)) {
            /**
             * invocation.addAttachmentsIfAbsent(context){@link RpcInvocation#addAttachmentsIfAbsent(Map)}should not be used here,
             * because the {@link RpcContext#setAttachment(String, String)} is passed in the Filter when the call is triggered
             * by the built-in retry mechanism of the Dubbo. The attachment to update RpcContext will no longer work, which is
             * a mistake in most cases (for example, through Filter to RpcContext output traceId and spanId and other information).
             */
            invocation.addObjectAttachments(contextAttachments);
        }
      //省略
 }
}  

由上述代码可以看出invocation的Attachments会被RpcContext的Attachments覆盖

duboo2.6.2

public abstract class AbstractInvoker<T> implements Invoker<T> { 
public Result invoke(Invocation inv) throws RpcException {
        //省略代码
        RpcInvocation invocation = (RpcInvocation) inv;
        invocation.setInvoker(this);
        if (attachment != null && attachment.size() > 0) {
            invocation.addAttachmentsIfAbsent(attachment);
        }
        Map<String, String> context = RpcContext.getContext().getAttachments();
        if (context != null) {
            invocation.addAttachmentsIfAbsent(context);
        }
       //省略代码
    }
}  

Comments (2)

haki created任务
haki set related repository to bryan31/TLog
haki changed description
铂赛东 changed issue state from 待办的 to 进行中
铂赛东 set assignee to 铂赛东
铂赛东 assigned collaborator 公子骏
铂赛东 added
 
enhancement
label
铂赛东 set priority to Main
铂赛东 set branch to v1.1.4
铂赛东 changed priority from Main to Serious
展开全部操作日志

@haki 感谢反馈,经过测试,确实有这个问题,我会尽快出1.1.4进行修复!

铂赛东 removed
 
enhancement
label
铂赛东 added
 
bug
label

@haki 已发布v1.1.4版本,修复了此问题~

铂赛东 changed issue state from 进行中 to 已完成

Sign in to comment

状态
Assignees
Milestones
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(3)
1102362 bryan31 1578940308 1216742 dt flys 1594991700
Java
1
https://gitee.com/dromara/TLog.git
git@gitee.com:dromara/TLog.git
dromara
TLog
TLog

Search