mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-07 06:08:00 +08:00
修复ClassUtil#scanJar未正确关闭文件问题
This commit is contained in:
parent
71ffe8a874
commit
46ce098add
@ -17,6 +17,7 @@ import org.dromara.hutool.core.collection.CollUtil;
|
|||||||
import org.dromara.hutool.core.collection.iter.EnumerationIter;
|
import org.dromara.hutool.core.collection.iter.EnumerationIter;
|
||||||
import org.dromara.hutool.core.exception.ExceptionUtil;
|
import org.dromara.hutool.core.exception.ExceptionUtil;
|
||||||
import org.dromara.hutool.core.io.IORuntimeException;
|
import org.dromara.hutool.core.io.IORuntimeException;
|
||||||
|
import org.dromara.hutool.core.io.IoUtil;
|
||||||
import org.dromara.hutool.core.io.file.FileNameUtil;
|
import org.dromara.hutool.core.io.file.FileNameUtil;
|
||||||
import org.dromara.hutool.core.io.resource.JarResource;
|
import org.dromara.hutool.core.io.resource.JarResource;
|
||||||
import org.dromara.hutool.core.io.resource.ResourceUtil;
|
import org.dromara.hutool.core.io.resource.ResourceUtil;
|
||||||
@ -366,11 +367,12 @@ public class ClassScanner implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫描jar包
|
* 扫描jar包,扫描结束后关闭jar文件
|
||||||
*
|
*
|
||||||
* @param jar jar包
|
* @param jar jar包
|
||||||
*/
|
*/
|
||||||
private void scanJar(final JarFile jar) {
|
private void scanJar(final JarFile jar) {
|
||||||
|
try{
|
||||||
String name;
|
String name;
|
||||||
for (final JarEntry entry : new EnumerationIter<>(jar.entries())) {
|
for (final JarEntry entry : new EnumerationIter<>(jar.entries())) {
|
||||||
name = StrUtil.removePrefix(entry.getName(), StrUtil.SLASH);
|
name = StrUtil.removePrefix(entry.getName(), StrUtil.SLASH);
|
||||||
@ -383,6 +385,9 @@ public class ClassScanner implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
IoUtil.closeQuietly(jar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user