dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

invocation.setAttachment can't affect in filter if RpcContext has same key

Open CodeIngL opened this issue 6 years ago • 1 comments

  • [ ] I have searched the issues of this repository and believe that this is not a duplicate.
  • [ ] I have checked the FAQ of this repository and believe that this is not a duplicate.

Environment

  • Dubbo version: 2.7.4.1
  • Operating System version: mac
  • Java version: 1.8

Steps to reproduce this issue

  1. invocation.setAttachment can't affect in filter if RPCContext has same Key

  2. a服务在filter中通过invocation设定a服务的kv对app=a,向b调用后,b向c发起调用,同时经过一致的filter设置b服务的kv对app=b,然后c服务接收。但是c无论从RPCContext还是invocation中,拿到的都是app=a的kv对

  3. 本质是因为AbstractInvoker中构建处理,总是RPCContext的优先级总是高于Invocation image

  4. 看起来这和规范相关,曾经的历史显示是有key不添加,现在的则是完全的覆盖。我想确定的是这是一个规范么,在filter中,不要使用invocation去设置,而是通过RpcContext来设定

  5. 注解来看,其只是为了自己的编程范式下,对结果的修正,并没有讨论这种修正会对invocation造成的潜在的影响

Pls. provide [GitHub address] to reproduce this issue.

Expected Result

c希望接收到由b服务的kv对app=b

Actual Result

c收到了上上游服务传递下来的kv对app=a

CodeIngL avatar Mar 23 '20 13:03 CodeIngL

我认为如你所理解的,可以认为这就是一个默认约束吧,在目前行为已经存在的情况下,我觉得我们应该避免再次修改这个优先级顺序。当前顺序为:RpcContext 优先级高于 Invocation,所以对于一些调用链路中,可能存在覆盖关系的 key,可优先设置到 RpcContext 中

chickenlj avatar Apr 23 '20 03:04 chickenlj