From 84a6132c2619eebf546643e0a2132d2d58c3be0d Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 3 Feb 2026 15:41:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`JschSessionPool`=E5=9B=9E?= =?UTF-8?q?=E6=94=B6=E5=AF=BC=E8=87=B4=E7=9A=84session=E6=9C=AA=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E9=97=AE=E9=A2=98=EF=BC=88issue#4223@Github=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++- .../src/main/java/cn/hutool/extra/ssh/JschSessionPool.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ceba7f8b2..2792291ea7 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/hutool-extra/src/main/java/cn/hutool/extra/ssh/JschSessionPool.java b/hutool-extra/src/main/java/cn/hutool/extra/ssh/JschSessionPool.java index a40073c762..64b74443f3 100755 --- a/hutool-extra/src/main/java/cn/hutool/extra/ssh/JschSessionPool.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/ssh/JschSessionPool.java @@ -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会话池,key:host,value:Session对象 */ - private final SimpleCache cache = new SimpleCache<>(); + private final SimpleCache cache = new SimpleCache<>(new SafeConcurrentHashMap<>()); /** * 获取Session,不存在返回null