haoyann opened a new issue #8654:
URL: https://github.com/apache/dubbo/issues/8654


   - [x] I have searched the [issues](https://github.com/apache/dubbo/issues) 
of this repository and believe that this is not a duplicate.
   - [x] I have checked the 
[FAQ](https://github.com/apache/dubbo/blob/master/FAQ.md) of this repository 
and believe that this is not a duplicate.
   
   ### Environment
   
   * Dubbo version: 3.0.2
   * Operating System version: xxx
   * Java version: 1.8
   
   ### Steps to reproduce this issue
   
   1. 创建 `GenericService` 调用完成之后销毁,代码类似下面
   ```
           ApplicationConfig applicationConfig = new ApplicationConfig();
           applicationConfig.setName("generic-call-consumer");
           RegistryConfig registryConfig = new RegistryConfig();
           registryConfig.setAddress("zookeeper://127.0.0.1:2181");
           ReferenceConfig<GenericService> referenceConfig = new 
ReferenceConfig<>();
           
referenceConfig.setInterface("org.test.apache.dubbo.interfaces.TestService");
           applicationConfig.setRegistry(registryConfig);
           referenceConfig.setApplication(applicationConfig);
           referenceConfig.setGeneric(true);
           referenceConfig.setAsync(true);
           referenceConfig.setTimeout(7000);
           GenericService genericService = referenceConfig.get();
           genericService.$invoke("test", null, null);
           referenceConfig.destroy();
   ```
   2. 在一次调用成功之后,再次调用抛出异常
   ```
   java.lang.IllegalStateException: Found multiple ReferenceConfigs with unique 
service name [org.test.apache.dubbo.interfaces.PeopleService], previous: 
<dubbo:reference async="true" sticky="false" timeout="7000" check="false" 
generic="true" interface="org.test.apache.dubbo.interfaces.TestService" />, 
later: <dubbo:reference async="true" timeout="7000" generic="true" 
interface="org.test.apache.dubbo.interfaces.PeopleService" />. There can only 
be one instance of ReferenceConfig with the same triple (group, interface, 
version). If multiple instances are required for the same interface, please use 
a different group or version.
        at 
org.apache.dubbo.config.context.ConfigManager.checkDuplicatedInterfaceConfig(ConfigManager.java:741)
 ~[dubbo-3.0.2.jar:3.0.2]
        at 
org.apache.dubbo.config.context.ConfigManager.addIfAbsent(ConfigManager.java:611)
 ~[dubbo-3.0.2.jar:3.0.2]
        at 
org.apache.dubbo.config.context.ConfigManager.addConfig(ConfigManager.java:490) 
~[dubbo-3.0.2.jar:3.0.2]
        at 
org.apache.dubbo.config.context.ConfigManager.addConfig(ConfigManager.java:461) 
~[dubbo-3.0.2.jar:3.0.2]
        at 
org.apache.dubbo.config.context.ConfigManager.addReference(ConfigManager.java:388)
 ~[dubbo-3.0.2.jar:3.0.2]
        at 
org.apache.dubbo.config.bootstrap.DubboBootstrap.reference(DubboBootstrap.java:446)
 ~[dubbo-3.0.2.jar:3.0.2]
        at 
org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:238) 
~[dubbo-3.0.2.jar:3.0.2]
        at 
org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:204) 
~[dubbo-3.0.2.jar:3.0.2]
        at 
org.test.apache.dubbo.consumer.HelloConsumer.test(HelloConsumer.java:51) 
~[classes/:na]
   ```
   3. 经过分析之后,`ReferenceConfig` 第一次创建完成之后将会缓存起来,之后同一个服务的 `ReferenceConfig`  
将从缓存中获取,并比较对象是否相等。但是`ReferenceConfig` 初始化完成之后会做一些属性的赋值,导致在此地方虽然是同一个服务的 
`ReferenceConfig` 的 `equals` 方法却返回 `false`
   prevConfig
   
![image](https://user-images.githubusercontent.com/43994656/131676603-95a19058-15fa-4189-868a-f0f4d927f09b.png)
   config
   
![image](https://user-images.githubusercontent.com/43994656/131676645-445c28ea-1684-4796-9231-a2debca497dc.png)
   4. 泛化调用创建的 `ReferenceConfig` 是否需要缓存,感觉有内存爆炸的风险,还有这里的 `equals` 
是否需要改进,现在看来即使是同一个服务,参数全部相同的情况下到这个地方也会是false。
   


-- 
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