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

[Dubbo-3169]Check future status before get(), return default value if not completed yet. #3185

Merged
merged 2 commits into from
Jan 11, 2019

Conversation

chickenlj
Copy link
Contributor

What is the purpose of the change

  • Check future status before get(), return the default value if not completed yet.
  • Add comment to announce AsyncRpcResult as unstable and should only be used internally.

Brief changelog

  • AsyncRpcResult

Verifying this change

run dubbo-samples-async

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Make sure there is a GITHUB_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GITHUB issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn clean install -DskipTests=false & mvn clean test-compile failsafe:integration-test to make sure unit-test and integration-test pass.
  • If this contribution is large, please follow the Software Donation Guide.

Check future status before get().
@codecov-io
Copy link

codecov-io commented Jan 10, 2019

Codecov Report

Merging #3185 into 2.7.0-release will decrease coverage by 0.04%.
The diff coverage is 0%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##             2.7.0-release    #3185      +/-   ##
===================================================
- Coverage            63.83%   63.78%   -0.05%     
  Complexity              75       75              
===================================================
  Files                  651      651              
  Lines                28317    28317              
  Branches              4793     4793              
===================================================
- Hits                 18076    18063      -13     
- Misses                7973     7982       +9     
- Partials              2268     2272       +4
Impacted Files Coverage Δ Complexity Δ
...ava/org/apache/dubbo/rpc/SimpleAsyncRpcResult.java 60% <ø> (ø) 0 <0> (ø) ⬇️
...main/java/org/apache/dubbo/rpc/AsyncRpcResult.java 32.75% <0%> (ø) 0 <0> (ø) ⬇️
.../remoting/transport/netty4/NettyClientHandler.java 75% <0%> (-11.12%) 0% <0%> (ø)
.../dubbo/remoting/transport/netty4/NettyChannel.java 61.17% <0%> (-4.71%) 0% <0%> (ø)
...e/dubbo/remoting/transport/netty/NettyChannel.java 57.64% <0%> (-4.71%) 0% <0%> (ø)
.../apache/dubbo/remoting/transport/AbstractPeer.java 58.69% <0%> (-4.35%) 0% <0%> (ø)
...he/dubbo/remoting/transport/netty/NettyServer.java 67.85% <0%> (-3.58%) 0% <0%> (ø)
...he/dubbo/registry/multicast/MulticastRegistry.java 63.79% <0%> (-1.73%) 0% <0%> (ø)
.../exchange/support/header/HeaderExchangeServer.java 58.11% <0%> (-1.71%) 0% <0%> (ø)
...rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java 72.5% <0%> (-1.67%) 0% <0%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 747b804...525fde9. Read the comment docs.

Copy link
Contributor

@khanimteyaz khanimteyaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chickenlj
Other than one minor comment which I have given, it looks fine to me.

@carryxyh
Copy link
Member

carryxyh commented Mar 25, 2019

@chickenlj
I found that the pr on this issue may cause an additional problem with CacheFilter:

String key = StringUtils.toArgumentString(invocation.getArguments());
Object value = cache.get(key);
if (value != null) {
    if (value instanceof ValueWrapper) {
        return new RpcResult(((ValueWrapper)value).get());
    } else {
        return new RpcResult(value);
    }
}
// In an asynchronous scenario, result.getValue() will return an empty RpcResult
Result result = invoker.invoke(invocation);
if (!result.hasException()) {
    // since the rpcResult#hasException will return false, this empty result will be cached.
    cache.put(key, new ValueWrapper(result.getValue()));
}
return result; 

In this scenario, CacheFilter will cache an empty RpcResult, which is incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants