kylixs commented on a change in pull request #9003:
URL: https://github.com/apache/dubbo/pull/9003#discussion_r728744389
##########
File path:
dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/deploy/DefaultApplicationDeployer.java
##########
@@ -924,8 +924,21 @@ private void destroyMetadataReports() {
private void destroyDynamicConfigurations() {
// TODO only destroy DynamicConfiguration of this application
// DynamicConfiguration may be cached somewhere, and maybe used during
destroy
- // destroy them may cause some troubles, so just clear instances cache
- //
ExtensionLoader.resetExtensionLoader(DynamicConfigurationFactory.class);
+ // destroy them may cause some troubles,
+ // but let them go also cause troubles such as configCenter connection
leak.
+ Optional<DynamicConfiguration> opt =
environment.getDynamicConfiguration()
+ .filter(v -> v instanceof CompositeDynamicConfiguration);
+ if (opt.isPresent()) {
+ CompositeDynamicConfiguration compositeDynamicConfiguration =
(CompositeDynamicConfiguration) opt.get();
+
compositeDynamicConfiguration.getInnerConfigurations().forEach(dynamicConfiguration
-> {
+ try {
+ dynamicConfiguration.close();
Review comment:
The `compositeDynamicConfiguration` only used in environment and it is
already destroyed in it. No need to release it again. You can debug it, the
`close()` method will be called when application is stopping.
```java
private void startConfigCenter() {
...
if (CollectionUtils.isNotEmpty(configCenters)) {
CompositeDynamicConfiguration compositeDynamicConfiguration = new
CompositeDynamicConfiguration();
for (ConfigCenterConfig configCenter : configCenters) {
// Pass config from ConfigCenterBean to environment
environment.updateExternalConfigMap(configCenter.getExternalConfiguration());
environment.updateAppExternalConfigMap(configCenter.getAppExternalConfiguration());
// Fetch config from remote config center
compositeDynamicConfiguration.addConfiguration(prepareEnvironment(configCenter));
}
environment.setDynamicConfiguration(compositeDynamicConfiguration);
}
...
}
```
--
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]