Commit 2c48aedd by 若依 Committed by Gitee

!144 修复War部署无法正常shutdown,ehcache内存泄漏

Merge pull request !144 from wayneliquan/master
parents 005418e0 87b8d032
package com.ruoyi.framework.manager; package com.ruoyi.framework.manager;
import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler; import com.ruoyi.framework.shiro.web.session.SpringSessionValidationScheduler;
import net.sf.ehcache.CacheManager;
import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -20,11 +22,15 @@ public class ShutdownManager ...@@ -20,11 +22,15 @@ public class ShutdownManager
@Autowired(required = false) @Autowired(required = false)
private SpringSessionValidationScheduler springSessionValidationScheduler; private SpringSessionValidationScheduler springSessionValidationScheduler;
@Autowired(required = false)
private EhCacheManager ehCacheManager;
@PreDestroy @PreDestroy
public void destroy() public void destroy()
{ {
shutdownSpringSessionValidationScheduler(); shutdownSpringSessionValidationScheduler();
shutdownAsyncManager(); shutdownAsyncManager();
shutdownEhCacheManager();
} }
/** /**
...@@ -61,4 +67,21 @@ public class ShutdownManager ...@@ -61,4 +67,21 @@ public class ShutdownManager
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }
} }
private void shutdownEhCacheManager()
{
try
{
logger.info("====关闭缓存====");
if (ehCacheManager != null)
{
CacheManager cacheManager = ehCacheManager.getCacheManager();
cacheManager.shutdown();
}
}
catch (Exception e)
{
logger.error(e.getMessage(), e);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment