You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/09/17 09:20:56 UTC

[dubbo] branch 3.0 updated: Catch exception of stop module when spring closing (#8835)

This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 647560e  Catch exception of stop module when spring closing (#8835)
647560e is described below

commit 647560e8fc3fcd694a33a7508b227b96c48cdc7e
Author: Gong Dewei <ky...@qq.com>
AuthorDate: Fri Sep 17 17:20:46 2021 +0800

    Catch exception of stop module when spring closing (#8835)
---
 .../spring/context/DubboDeployApplicationListener.java       | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java
index ad09ebd..d3313668 100644
--- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java
+++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java
@@ -111,10 +111,14 @@ public class DubboDeployApplicationListener implements ApplicationListener<Appli
     }
 
     private void onContextClosedEvent(ContextClosedEvent event) {
-        Object value = moduleModel.getAttribute(ModelConstants.KEEP_RUNNING_ON_SPRING_CLOSED);
-        boolean keepRunningOnClosed = Boolean.parseBoolean(String.valueOf(value));
-        if (!keepRunningOnClosed) {
-            moduleModel.getDeployer().stop();
+        try {
+            Object value = moduleModel.getAttribute(ModelConstants.KEEP_RUNNING_ON_SPRING_CLOSED);
+            boolean keepRunningOnClosed = Boolean.parseBoolean(String.valueOf(value));
+            if (!keepRunningOnClosed && !moduleModel.isDestroyed()) {
+                moduleModel.destroy();
+            }
+        } catch (Exception e) {
+            logger.error("An error occurred when stop dubbo module: " + e.getMessage(), e);
         }
     }