From 0e240cb2441dc0dbff66cb1dbc047910f0e03f1e Mon Sep 17 00:00:00 2001 From: cj Date: Fri, 28 Dec 2018 23:05:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E9=A3=8E=E6=A0=BC=E5=92=8C?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/ApplicationShutdownBean.java | 34 +++++++++++++------ .../SpringSessionValidationScheduler.java | 10 ++++-- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationShutdownBean.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationShutdownBean.java index 0aa36432b..715b4a834 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationShutdownBean.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationShutdownBean.java @@ -17,32 +17,44 @@ import java.util.concurrent.TimeUnit; * @Date: 2018/12/28 */ @Component -public class ApplicationShutdownBean { +public class ApplicationShutdownBean +{ private static final Logger logger = LoggerFactory.getLogger("sys-user"); @Autowired(required = false) private SpringSessionValidationScheduler springSessionValidationScheduler; @PreDestroy - public void destroy(){ + public void destroy() + { shutdownSpringSessionValidationScheduler(); shutdownAsyncManager(); } - private void shutdownSpringSessionValidationScheduler(){ + private void shutdownSpringSessionValidationScheduler() + { if(springSessionValidationScheduler != null && springSessionValidationScheduler.isEnabled()) - try { - logger.info("关闭会话验证任务"); - springSessionValidationScheduler.disableSessionValidation(); - } catch (Exception e) { - logger.error(e.getMessage(),e); + { + try + { + logger.info("关闭会话验证任务"); + springSessionValidationScheduler.disableSessionValidation(); + } + catch (Exception e) + { + logger.error(e.getMessage(),e); + } } } - private void shutdownAsyncManager(){ - try { + private void shutdownAsyncManager() + { + try + { logger.info("关闭后台任务线程池"); AsyncManager.me().shutdown(10, TimeUnit.SECONDS); - } catch (Exception e) { + } + catch (Exception e) + { logger.error(e.getMessage(),e); } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java index c8e7d4a20..e94cf6782 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/web/session/SpringSessionValidationScheduler.java @@ -134,11 +134,15 @@ public class SpringSessionValidationScheduler implements SessionValidationSchedu log.debug("Stopping Spring Scheduler session validation job..."); } - if(this.enabled){ + if(this.enabled) + { executorService.shutdown(); - try { + try + { executorService.awaitTermination(10,TimeUnit.SECONDS); - } catch (InterruptedException e) { + } + catch (InterruptedException e) + { log.error(e.getMessage(),e); } }