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

ReferenceConfigCache cannot recover in 2.7.0. #3781

Closed
2 tasks done
haiyang1985 opened this issue Apr 1, 2019 · 1 comment
Closed
2 tasks done

ReferenceConfigCache cannot recover in 2.7.0. #3781

haiyang1985 opened this issue Apr 1, 2019 · 1 comment
Assignees

Comments

@haiyang1985
Copy link
Member

haiyang1985 commented Apr 1, 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.7.0
  • Operating System version: mac
  • Java version: 1.8

Steps to reproduce this issue

  1. start the consumer without provider, and it will throw "No Provider" exception. Below is not the full of my code, simplify on the ReferenceConfig.
try{
  ReferenceConfigCache cache = ReferenceConfigCache.getCache();
  Object proxy = cache.get(new ReferenceConfig());
}catch (Throwable e){
  e.printStackTrace();
}
  1. Start the provider
  2. Always get null even the provider started.
    Object proxyNew = cache.get(config);

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

Expected Result

We are able to get proxy after start up the provider.
Object proxyNew = cache.get(config);

Actual Result

What actually happens?
cache always return null even provider started.

I think, we have to return null once consumer startup failed.

public <T> T get(ReferenceConfig<T> referenceConfig) {
    String key = generator.generateKey(referenceConfig);

    ReferenceConfig<?> config = cache.get(key);
    if (config != null) {
        return (T) config.get();
    }

    T t = referenceConfig.get();
    if (null == t){
        return null;
    }else{
        cache.putIfAbsent(key, referenceConfig);
        return t;
    }
}

Otherwise, the consumer cannot recover, as it have been initialized. The solution of #2233 is not able to resolve the issue.

private void init() {
    if (initialized) {
        return;
    }
    initialized = true;
}
@haiyang1985 haiyang1985 changed the title ReferenceConfigCache cannot recover with providers. ReferenceConfigCache cannot recover in 2.7.0. Apr 1, 2019
@haiyang1985
Copy link
Member Author

My mistake, the solution of #2233 is able to solve the issue.

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

No branches or pull requests

1 participant