Pre-check

  • [x] I am sure that all the content I provide is in English.

Search before asking

  • [x] I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

dubbo-attachment-issues

The documentation claims that Dubbo 3 has fixed the attachment parameter transparency issue, but the code still silently propagates these parameters. The root cause is in ConsumerContextFilter, where supportedSelectors defaults to an empty set.

if (CollectionUtils.isNotEmpty(supportedSelectors)) {
    xxxxx
} else {
    ((RpcInvocation) invocation)
            .addObjectAttachments(RpcContext.getServerAttachment().getObjectAttachments());
}

Steps to reproduce this issue

Prepare three applications with the following relationships: A ---> B ---> C

A-->B: RpcContext.getClientAttachment().setAttachment("jyz", "pass-through");

What you expected to happen

The attachment received by C should not include {"jyz":"pass-through"}.

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • [x] Yes I am willing to submit a pull request on my own!

Code of Conduct

Comment From: zrlw

The attachment received by C includes {"jyz":"pass-through"}.

Do you expect to happen this??

Comment From: am-JYZ

Do you expect to happen this??

@zrlw Yes, this is my test result.

Comment From: zrlw

Do you expect to happen this??

@zrlw Yes, this is my test result.

if all the result are your expected, why you submit it as a issue?

Comment From: am-JYZ

Could you take a look at the description in my issue?

https://cn.dubbo.apache.org/en/overview/mannual/java-sdk/tasks/framework/attachment/#reading-implicit-parameters-1

Comment From: zrlw

What you expected to happen means the correct result that should be if the issue is fixed.

Comment From: am-JYZ

Prepare three applications with the following relationships: A ---> B ---> C

A-->B: RpcContext.getClientAttachment().setAttachment("jyz", "pass-through"); B-->C: The attachment received by C includes {"jyz":"pass-through"}.

Do you expect to happen this??


I misunderstood what you said; I hope the attachment received by C does not include {"jyz":"pass-through"}.

The context when B calls C is clean and will not include the parameters originally set in A

Comment From: am-JYZ

@zrlw So, do you consider this is a bug or a documentation error?

Comment From: zrlw

@zrlw So, do you consider this is a bug or a documentation error?

could you provide a pr?

Comment From: wcy666103

https://github.com/apache/dubbo-website/pull/2987/files

Comment From: zrlw

https://github.com/apache/dubbo-website/blob/master/content/en/overview/mannual/java-sdk/tasks/framework/attachment.md

For Dubbo2, parameters set on endpoint A will also be passed to endpoint C when B continues to call C (leading to parameter pollution issues). However, for Dubbo3, the context when B calls C is clean and will not include the parameters originally set in A.

Comment From: am-JYZ

serverContext also has this problem, The root cause is in ContextFilter#onResponse.

A ---> B ---> C

C: RpcContext.getServerContext().setAttachment("response_key", "value")
B: will receive  `{"response_key", "value"}` in the serverContext
A: will also receive `{"response_key", "value"}`.

I think A should not receive {"response_key", "value"},but documentation doesn't cover this scenario. Could you please help confirm if this is a bug or expected behavior. @zrlw

Comment From: zrlw

I think A should not receive {"response_key", "value"},but documentation doesn't cover this scenario. Could you please help confirm if this is a bug or expected behavior. @zrlw

https://github.com/apache/dubbo-website/blob/master/content/en/overview/mannual/java-sdk/tasks/framework/attachment.md ONLY said endpoint A parametes will be cleaned when calling C from B. As for me, if you don't want A got C response, you should clean it by yourself.

Comment From: zrlw

Oops, According to other members saying, For Dubbo2, parameters set on endpoint A will also be passed to endpoint C when B continues to call C (leading to parameter pollution issues). However, for Dubbo3, the context when B calls C is clean and will not include the parameters originally set in A. should be modified by Parameters set on endpoint A will also be passed to endpoint C when B continues to call C. to meet the requirements of existed customers.

Comment From: am-JYZ

Parameters set on endpoint A will also be passed to endpoint C when B continues to call C

@zrlw Thanks! Is this final?

Comment From: zrlw

Parameters set on endpoint A will also be passed to endpoint C when B continues to call C

@zrlw Thanks! Is this final?

yes, both ServerContext and ServerAttachment do the same behavior for implicit passing.