saleson opened a new issue, #10044:
URL: https://github.com/apache/dubbo/issues/10044

   
   ### Environment
   
   * Dubbo version: 3.0.8
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   复现的代码:
   ```java
   public static GenericService getService(String serviceName, String version){
     ReferenceConfig<GeniricService> refConf = new ReferenceConfig();
     refConf.setProtocol("zookeeper");
     refConf.setAddress(registryAddress);
     refConf.setRegistry(registryConfig);
     refConf.setGeneric("true");
     refConf.setInterface(serviceName);
     refConf.setVersion(version);
     refConf.setTimeout(5000);
     return DubboBootstrap.getInstance().getCache().get(refConf);
   }
   ```
   
   
   ### Expected Behavior
   
   从缓存中获取GenericService
   
   ### Actual Behavior
   
   
没有从缓存中获取,而是直接调用了ReferenceConfig.get(),且执行了ReferenceConfig.init()另外创建了新的GenericService,
 在zookeeper上也在相应的service节点下添加了consumer节点。
   
   
   
   ### Reason
   DubboBootstrap.getInstance().getCache()返回的是 
CompositeReferenceCache类型的对象,CompositeReferenceCache.get(ReferenceConfigBase)方法没有从缓存中取已经创建好的代理类,而是直接调用了ReferenceConfigBase.get()方法,由于ReferenceConfigBase是一个新对象,ReferenceConfigBase.ref==null,最终执行ReferenceConfigBase.init()方法创建代理类并新增consumer节点。
   CompositeReferenceCache.get(ReferenceConfigBase)代码如下:
   <img width="765" alt="image" 
src="https://user-images.githubusercontent.com/4346834/168599344-1e70b99d-3c90-485f-b0b4-883ada28b64d.png";>
   
   
   该问题在https://github.com/apache/dubbo/issues/10012 
也反映过,但仅修复了SimpleReferenceCache类中的bug。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to