mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-05 13:17:58 +08:00
修复ClassUtil#scanJar未正确关闭文件问题
This commit is contained in:
parent
b2b6a233dd
commit
0101ab5668
@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.23(2023-10-27)
|
||||
# 5.8.23(2023-10-30)
|
||||
|
||||
### 🐣新特性
|
||||
* 【json 】 改进TemporalAccessorSerializer支持dayOfMonth和month枚举名(issue#I82AM8@Gitee)
|
||||
@ -22,7 +22,8 @@
|
||||
* 【core 】 修复DataSize.parse(size)不支持空格问题(issue#I88Z4Z@Gitee)
|
||||
* 【http 】 修复SimpleServer在添加的HttpFilter中有获取请求参数时报错问题(issue#3343@Github)
|
||||
* 【http 】 修复options请求无响应体问题
|
||||
* 【core 】 ImgUtil的sliceByRowsAndCols背景无法透明问题(issue#3347@Gitee)
|
||||
* 【core 】 ImgUtil的sliceByRowsAndCols背景无法透明问题(issue#3347@Github)
|
||||
* 【core 】 修复ClassUtil#scanJar未正确关闭文件问题(issue#3361@Github)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.22(2023-09-13)
|
||||
|
@ -5,6 +5,7 @@ import cn.hutool.core.collection.EnumerationIter;
|
||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.io.resource.ResourceUtil;
|
||||
import cn.hutool.core.util.*;
|
||||
|
||||
@ -356,22 +357,26 @@ public class ClassScanner implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫描jar包
|
||||
* 扫描jar包,扫描结束后关闭jar文件
|
||||
*
|
||||
* @param jar jar包
|
||||
*/
|
||||
private void scanJar(JarFile jar) {
|
||||
String name;
|
||||
for (JarEntry entry : new EnumerationIter<>(jar.entries())) {
|
||||
name = StrUtil.removePrefix(entry.getName(), StrUtil.SLASH);
|
||||
if (StrUtil.isEmpty(packagePath) || name.startsWith(this.packagePath)) {
|
||||
if (name.endsWith(FileUtil.CLASS_EXT) && false == entry.isDirectory()) {
|
||||
final String className = name//
|
||||
try{
|
||||
String name;
|
||||
for (JarEntry entry : new EnumerationIter<>(jar.entries())) {
|
||||
name = StrUtil.removePrefix(entry.getName(), StrUtil.SLASH);
|
||||
if (StrUtil.isEmpty(packagePath) || name.startsWith(this.packagePath)) {
|
||||
if (name.endsWith(FileUtil.CLASS_EXT) && false == entry.isDirectory()) {
|
||||
final String className = name//
|
||||
.substring(0, name.length() - 6)//
|
||||
.replace(CharUtil.SLASH, CharUtil.DOT);//
|
||||
addIfAccept(loadClass(className));
|
||||
addIfAccept(loadClass(className));
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
IoUtil.close(jar);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user