我正在通过Redis实现Spring Session。
我收到以下异常:
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:compile
io.netty
例外是known, unfixed defect。
是否有解决此问题的方法?我已经尝试过以下方法:
lettuce-core
的发布:相同的例外lettuce-core
版本5.0.5.RELEASE:获取NoSuchMethodError:io.lettuce.core.api.StatefulConnection.closeAsync()是否有解决此问题的方法?
错误报告注释表明,这将减轻问题,但不能完全解决。也许以下方法对于您的用例就足够了?
public class MyServletContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
}
public void contextDestroyed(ServletContextEvent event) {
io.netty.util.internal.InternalThreadLocalMap.destroy();
}
}