我正在使用Redis实现Spring会话。
我得到了以下例外:
SEVERE [RMI TCP Connection(3)-127.0.0.1]
org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks
The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal]
(value [java.lang.ThreadLocal@e9d8bb]) and a value of type [io.netty.util.internal.InternalThreadLocalMap]
(value [io.netty.util.internal.InternalThreadLocalMap@1559b23])
but failed to remove it when the web application was stopped. Threads are going to be
renewed over time to try and avoid a probable memory leak.我有以下依赖关系:
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>5.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>我可以看到lettuce-core正在拖动io.netty类:
[INFO] +- io.lettuce:lettuce-core:jar:5.2.1.RELEASE:compile
[INFO] | +- io.netty:netty-common:jar:4.1.43.Final:compile
[INFO] | +- io.netty:netty-handler:jar:4.1.43.Final:compile
[INFO] | | +- io.netty:netty-buffer:jar:4.1.43.Final:compile
[INFO] | | \- io.netty:netty-codec:jar:4.1.43.Final:compile
[INFO] | +- io.netty:netty-transport:jar:4.1.43.Final:compile
[INFO] | | \- io.netty:netty-resolver:jar:4.1.43.Final:compile
[INFO] | \- io.projectreactor:reactor-core:jar:3.3.0.RELEASE:compile
[INFO] | \- org.reactivestreams:reactive-streams:jar:1.0.3:compileio.netty异常是一个已知的未固定的缺陷。
有办法解决这个问题吗?我已经尝试过以下几种方法:
lettuce-core的version :相同的异常lettuce-core:Get NoSuchMethodError: NoSuchMethodError有解决这个问题的办法吗?
发布于 2020-02-10 21:13:12
bug报告的注释表明这将减轻问题,但并不能完全解决问题。也许下面这样的方法对于您的用例来说已经足够好了?
public class MyServletContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
}
public void contextDestroyed(ServletContextEvent event) {
io.netty.util.internal.InternalThreadLocalMap.destroy();
}
}https://stackoverflow.com/questions/60118193
复制相似问题