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 0aa36432..715b4a83 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 c8e7d4a2..e94cf678 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); } }