You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "haiyang1985 (GitHub)" <gi...@apache.org> on 2019/04/01 06:04:24 UTC
[GitHub] [incubator-dubbo] haiyang1985 opened issue #3781:
ReferenceConfigCache cannot recover with providers.
- [ ] I have searched the [issues](https://github.com/apache/incubator-dubbo/issues) of this repository and believe that this is not a duplicate.
- [ ] I have checked the [FAQ](https://github.com/apache/incubator-dubbo/blob/master/FAQ.md) 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();
}
```
2. Start the provider
3. 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;
}
```
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3781 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org