修复JschSessionPool回收导致的session未关闭问题(issue#4223@Github)

This commit is contained in:
Looly
2026-02-03 15:41:42 +08:00
parent b3ec45a0ac
commit 84a6132c26
2 changed files with 4 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
# 🚀Changelog
-------------------------------------------------------------------------------------------------------------
# 5.8.44(2026-02-01)
# 5.8.44(2026-02-03)
### 🐣新特性
* 【core 】 `NumberUtil.parseNumber`增加支持科学计数法pr#4211@Github
* 【captcha】 `AbstractCaptcha`增加`setStroke`方法支持线条粗细issue#IDJQ15@Gitee
@@ -16,6 +16,7 @@
* 【core 】 修复`TransMap.computeIfAbsent`mappingFunction处理不一致问题issue#IDM6UR@Gitee
* 【core 】 修复`MultiResource`游标歧义问题issue#IDNAOY@Gitee
* 【core 】 修复`BufferUtil`copy歧义问题issue#IDN097@Gitee
* 【core 】 修复`JschSessionPool`回收导致的session未关闭问题issue#4223@Github
-------------------------------------------------------------------------------------------------------------
# 5.8.43(2026-01-04)

View File

@@ -1,6 +1,7 @@
package cn.hutool.extra.ssh;
import cn.hutool.core.lang.SimpleCache;
import cn.hutool.core.map.SafeConcurrentHashMap;
import cn.hutool.core.util.StrUtil;
import com.jcraft.jsch.Session;
@@ -22,7 +23,7 @@ public enum JschSessionPool {
/**
* SSH会话池keyhostvalueSession对象
*/
private final SimpleCache<String, Session> cache = new SimpleCache<>();
private final SimpleCache<String, Session> cache = new SimpleCache<>(new SafeConcurrentHashMap<>());
/**
* 获取Session不存在返回null