AlbumenJ commented on a change in pull request #9003:
URL: https://github.com/apache/dubbo/pull/9003#discussion_r726715837
##########
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();
+ } catch (Throwable ignored) {
+ logger.warn(ignored.getMessage(), ignored);
+ }
+ });
+ }
+ environment.destroy();
Review comment:
environment 是由 applicationModel 持有的,不应该由 deployer 去销毁
##########
File path:
dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ApplicationModel.java
##########
@@ -224,7 +224,7 @@ public void onDestroy() {
}
if (environment != null) {
- environment.destroy();
+ // just set null here, destroy environment at
DefaultApplicationDeployer destroyDynamicConfigurations().
Review comment:
deployer的destroy行为在这行之前,为了保证 environment 被销毁这里不能注释掉(兼容不使用 deployer 的场景)
##########
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:
默认动态配置中心是不支持销毁的
```java
org.apache.dubbo.common.config.configcenter.DynamicConfiguration
@Override
default void close() throws Exception {
throw new UnsupportedOperationException();
}
```
--
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]