redis - 使用 Redis 实现 Spring Session 时出现“io.netty”异常
问题描述
我正在用 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
例外是一个已知的、未修复的缺陷。
有没有办法解决这个问题?我已经尝试过以下方法:
- 使用的版本 5.1.8.RELEASE
lettuce-core
:相同的异常 - 使用版本 5.0.5.RELEASE 的
lettuce-core
:Get 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();
}
}
推荐阅读
- arrays - jq:语法错误,使用 jq 输入意外的 ':'?
- dax - DAX 计算上个月的变化——但 Jan 不同
- javascript - 如何更改 matMenuTriggerFor 区域仅在箭头上触发
- embedded - 首次为 Tiva Launchpad TI TM4C1294XL MCU 设置 Keil 时出现问题
- c# - Prevent Combobox values repeating When select Items form another combobox
- javascript - “user.setStatus”不更新机器人的状态 Discord.JS
- ios - 如何通过 SwiftUI 中的 @EnvironnementObject 路由器传递参数?
- reactjs - 创建离子应用时,npm 无法解析依赖树 React
- r - lapply - 环境中存在命名参数时传递和不传递参数的区别
- stm32cubeide - TouchGFX:如何处理按下/未按下按钮的指令