Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cusumer设置使用异步调用方法时,RpcContext中的ServerContext参数,无法从provider传到cusumer #3620

Closed
2 tasks done
cinbo-github opened this issue Mar 8, 2019 · 9 comments
Assignees
Labels
type/bug Bugs to being fixed
Milestone

Comments

@cinbo-github
Copy link

cinbo-github commented Mar 8, 2019

  • 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.6.6
  • Operating System version: MacOS 10.14.3
  • Java version: 1.8.0_171

Steps to reproduce this issue

When I try to use RpcContext.getServerContext to pass data from provider to cusumer,if the method runs in sync mode, it works( Provider uses RpcContext.getServerContext().setAttachment to set Key-Value data,then Consumer uses RpcContext.getServerContext().getAttachment to get the Key-Value Data.). But if the method runs in async mode, it doesn't works. Consumer can't get the Key-Value by RpcContext.getServerContext().getAttachment.

  1. xxx
  2. xxx

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

Expected Result

What do you expected from the above steps?

Actual Result

What actually happens?

If there is an exception, please attach the exception trace:

Just put your stack trace here!
@cinbo-github
Copy link
Author

the issue still exists

@tswstarplanet
Copy link
Contributor

Can you pls provide a demo to reproduce the problem ?

@chickenlj
Copy link
Contributor

Thanks for reporting, I can reproduce from the official sample 'dubbo-samples-async-original-future', will try to figure it out.

@chickenlj chickenlj added the type/bug Bugs to being fixed label Mar 12, 2019
@chickenlj chickenlj added this to the 2.7.1 milestone Mar 12, 2019
@tswstarplanet
Copy link
Contributor

I find this problem also exists in sync mode. It is because the code following:
ContextFilter.java
image
The ContextFilter will remove ServerContext after invoke. So the attachments are removed.

@lizanle521
Copy link

The ContextFilter will remove ServerContext after invoke. So the attachments are removed.

are you sure about this ? i don't think so . invoker.invoke returns AyncRpcResult first. then RpcContext clear it's context .

@tswstarplanet
Copy link
Contributor

@lizanle521 You can debug it

@lizanle521
Copy link

lizanle521 commented Mar 13, 2019

@tswstarplanet yes,i did it yesterday . and i doubted it also .but it is not the cause .
as i said bebore, before RpcContext.removeContext , invoker.invoke return a AsyncRpcResult object.
that object hold a copy of serverConext .

@tswstarplanet
Copy link
Contributor

sorry, I didn't intend to edit your reply, it is a misoperation

@tswstarplanet
Copy link
Contributor

I just test the sync invoke

@cvictory cvictory modified the milestones: 2.7.1, 2.7.2 Mar 14, 2019
chickenlj added a commit to chickenlj/incubator-dubbo that referenced this issue Mar 19, 2019
chickenlj added a commit to chickenlj/incubator-dubbo that referenced this issue Mar 20, 2019
Jeff-Lv pushed a commit that referenced this issue Apr 12, 2019
* Result implement CF

* Result implement CF

* Result implement CF

* Add AsyncRpcResult

* Fix bugs and refactor Filter

* Try to add onSend onError for Filter

* invoke different filter method according to result status.

*  make generic work with async call, including add $invokeAsync

* refactor legacy Filter implementation to work with onResponse.

* demo changes

* Fixes #3620, provider attachment lose on consumer side, fix this by reverting RpcContext copy

* AsyncRpcResult should always holds an Invocation instance

* refactor filter signature

* reimplement embedded Filters

* use ProviderModel modification in 3.x

* Fix address notification processing workflow after merging 3.x branch

* Fix UT

* Fix UT

* Unit test of JValidator; Clean code of JValidator (#3723)

* Fixes #3625 (#3730)

use constant to replace magic number

* Fix conflict when merging master and 3.x

* Fix conflict when merging master and 3.x

* Result interface itself has Future status.

* Fix DefaultFuture UT

* Wrap all protocol Invoker with AsyncToSyncInvoker & Fix UT

* Add license

* fix UT

* Fix ut in MonitorFilterTest

* avoid duplicate async to sync wrapper

* return async result in CacheFilter.

* fix UT in CacheFilterTest

* Add generic condition check to GenericFilter callback.

* Fix UT

* Get generic from RpcContext if the value in Invocation is empty.

* Fix RSocketProtocol to meet AbstractProtocol adjustment

* rename RpcResult to AppResponse to help avoid confusion with AsyncRpcResult.

* RSocket module switch to AsyncRpcResult
chickenlj added a commit to chickenlj/incubator-dubbo that referenced this issue May 8, 2019
* Result implement CF

* Result implement CF

* Result implement CF

* Add AsyncRpcResult

* Fix bugs and refactor Filter

* Try to add onSend onError for Filter

* invoke different filter method according to result status.

*  make generic work with async call, including add $invokeAsync

* refactor legacy Filter implementation to work with onResponse.

* demo changes

* Fixes apache#3620, provider attachment lose on consumer side, fix this by reverting RpcContext copy

* AsyncRpcResult should always holds an Invocation instance

* refactor filter signature

* reimplement embedded Filters

* use ProviderModel modification in 3.x

* Fix address notification processing workflow after merging 3.x branch

* Fix UT

* Fix UT

* Unit test of JValidator; Clean code of JValidator (apache#3723)

* Fixes apache#3625 (apache#3730)

use constant to replace magic number

* Fix conflict when merging master and 3.x

* Fix conflict when merging master and 3.x

* Result interface itself has Future status.

* Fix DefaultFuture UT

* Wrap all protocol Invoker with AsyncToSyncInvoker & Fix UT

* Add license

* fix UT

* Fix ut in MonitorFilterTest

* avoid duplicate async to sync wrapper

* return async result in CacheFilter.

* fix UT in CacheFilterTest

* Add generic condition check to GenericFilter callback.

* Fix UT

* Get generic from RpcContext if the value in Invocation is empty.

* Fix RSocketProtocol to meet AbstractProtocol adjustment

* rename RpcResult to AppResponse to help avoid confusion with AsyncRpcResult.

* RSocket module switch to AsyncRpcResult
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Bugs to being fixed
Projects
None yet
Development

No branches or pull requests

5 participants