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-2233] fix reference config cache issue #2233 #2347

Closed
wants to merge 1 commit into from
Closed

[Dubbo-2233] fix reference config cache issue #2233 #2347

wants to merge 1 commit into from

Conversation

YoungHu
Copy link
Contributor

@YoungHu YoungHu commented Aug 25, 2018

What is the purpose of the change

fix issue #2233

Brief changelog

fix the referenceconfig cache null forever if no provider and then provider startup

Verifying this change

  1. provider not startup
  2. invoke with reference cache get null
  3. provider startup
  4. invoker with reference cache again get what you want

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

  • Make sure there is a GITHUB_issue filed 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 & 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.

@codecov-io
Copy link

Codecov Report

Merging #2347 into master will decrease coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2347      +/-   ##
============================================
- Coverage     54.85%   54.78%   -0.08%     
+ Complexity     5241     5237       -4     
============================================
  Files           573      573              
  Lines         25456    25458       +2     
  Branches       4537     4538       +1     
============================================
- Hits          13965    13948      -17     
- Misses         9399     9415      +16     
- Partials       2092     2095       +3
Impacted Files Coverage Δ Complexity Δ
...pache/dubbo/config/utils/ReferenceConfigCache.java 77.55% <100%> (+0.95%) 12 <0> (+1) ⬆️
...apache/dubbo/rpc/protocol/dubbo/FutureAdapter.java 58.06% <0%> (-6.46%) 3% <0%> (ø)
...ubbo/rpc/protocol/dubbo/ChannelWrappedInvoker.java 41.66% <0%> (-4.17%) 3% <0%> (ø)
...rpc/protocol/dubbo/telnet/InvokeTelnetHandler.java 54.21% <0%> (-3.62%) 13% <0%> (-2%)
...he/dubbo/remoting/transport/netty/NettyServer.java 67.85% <0%> (-3.58%) 8% <0%> (-1%)
.../apache/dubbo/rpc/protocol/dubbo/DubboInvoker.java 68.33% <0%> (-3.34%) 11% <0%> (ø)
...a/org/apache/dubbo/monitor/dubbo/DubboMonitor.java 87.85% <0%> (-1.87%) 15% <0%> (ø)
...dubbo/rpc/protocol/dubbo/CallbackServiceCodec.java 77.2% <0%> (-1.48%) 29% <0%> (ø)
.../src/main/java/org/apache/dubbo/rpc/RpcStatus.java 57.89% <0%> (-1.06%) 18% <0%> (ø)
...apache/dubbo/rpc/protocol/dubbo/DubboProtocol.java 58.33% <0%> (-0.84%) 30% <0%> (-1%)
... and 2 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 f720ccb...5a2c7d6. Read the comment docs.

@diecui1202
Copy link

diecui1202 commented Aug 29, 2018

@YoungHu I try to reproduce the problem with the following client code,

        ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
        reference.setApplication(new ApplicationConfig("first-dubbo-client"));
        reference.setRegistry(new RegistryConfig("multicast://224.5.6.7:1234"));
        reference.setInterface(DemoService.class);
        System.in.read(); // stop provider before continuing

        ReferenceConfigCache cache = ReferenceConfigCache.getCache();
        try {
            DemoService greetingsService = cache.get(reference);

            String message = greetingsService.sayHello("dubbo");
            System.out.println(message);
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.in.read(); // start provider before continuing

        DemoService greetingsService = cache.get(reference);
        // GreetingsService greetingsService = reference.get();
        String message = greetingsService.sayHello("dubbo");
        System.out.println(message);

With the newest master, it works. That means the second invocation succeed.

Is my client suitable for reproducing the problem ?

@YoungHu
Copy link
Contributor Author

YoungHu commented Aug 29, 2018

there is something wrong with your client code, first time you already up the provider, please check the test code i commit with this PR, you can find that test will failed without change the ReferenceConfigCache.java code

@diecui1202
Copy link

@YoungHu My mistake. But the following code can also get the right response.

        // not start provider, just run client 
        ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
        reference.setApplication(new ApplicationConfig("first-dubbo-client"));
        reference.setRegistry(new RegistryConfig("multicast://224.5.6.7:1234"));
        reference.setInterface(DemoService.class);

        ReferenceConfigCache cache = ReferenceConfigCache.getCache();
        try {
            DemoService greetingsService = cache.get(reference);

            String message = greetingsService.sayHello("dubbo");
            System.out.println(message);
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.in.read(); // start provider before continuing

        DemoService greetingsService = cache.get(reference);
        // GreetingsService greetingsService = reference.get();
        String message = greetingsService.sayHello("dubbo");
        System.out.println(message);

So what's my code's problem ?

@YoungHu
Copy link
Contributor Author

YoungHu commented Aug 29, 2018

below is my code and test result, dubbo version is 2.6.2. why can't reproduce what I said, you may need find it out by yourself. because i can't get more information from you.
wx20180829-211015

@diecui1202
Copy link

OK, thanks, I'll try it with the zk registry.

@diecui1202
Copy link

I use the newest master branch, it's ok. Refer to #1999

So could u please file a new PR?

@diecui1202 diecui1202 added the status/waiting-for-feedback Need reporters to triage label Aug 30, 2018
@YoungHu
Copy link
Contributor Author

YoungHu commented Aug 31, 2018

confirmed this issue fix at master branch with #1999 ,close this one

@YoungHu YoungHu closed this Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/waiting-for-feedback Need reporters to triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants