Merge pull request #9548 from tejasae-afk/fix/close-inputstream-in-parse

Close InputStream in parse
This commit is contained in:
JEECG 2026-04-15 23:05:13 +08:00 committed by GitHub
commit d48507a7b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,7 +73,7 @@ public class TikaDocumentParser {
AssertUtils.assertNotEmpty("请选择文件", file); AssertUtils.assertNotEmpty("请选择文件", file);
try { try {
// 用于解析(使用FileInputStream避免file.toPath()在Linux非UTF-8环境下中文文件名报错) // 用于解析(使用FileInputStream避免file.toPath()在Linux非UTF-8环境下中文文件名报错)
InputStream isForParsing = new FileInputStream(file); try (InputStream isForParsing = new FileInputStream(file)) {
// 使用 Tika 自动检测 MIME 类型 // 使用 Tika 自动检测 MIME 类型
String fileName = file.getName().toLowerCase(); String fileName = file.getName().toLowerCase();
//后缀 //后缀
@ -93,6 +93,7 @@ public class TikaDocumentParser {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
}
/** /**
* langchain4j 内部解析器 * langchain4j 内部解析器