🐞 fix(all): 项目中每次跟踪文件都会开启一个定时线程,全部关闭,仅仅会关闭其中一个线程

This commit is contained in:
小吾立 2024-08-06 16:01:31 +08:00
parent 02cceda0f0
commit baa1c8473f
3 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,13 @@
# 🚀 版本日志
## 2.11.9.1-beta
### 🐞 解决BUG、优化功能
1. 【all】修复 多会话使用文件跟踪器可能出现多个线程未关闭问题(感谢[@沐剑屏](https://gitee.com/MuJianPing) [Gitee issues IAI0I1](https://gitee.com/dromara/Jpom/issues/IAI0I1)
------
## 2.11.8.5-beta (2024-08-02)
### 🐞 解决BUG、优化功能

View File

@ -53,7 +53,7 @@ public class AgentFileTailWatcher<T extends AutoCloseable> extends BaseFileTailW
*/
public static boolean addWatcher(File file, Charset charset, Session session) throws IOException {
if (!FileUtil.isFile(file)) {
log.warn(I18nMessageUtil.get("i18n.file_or_directory_not_found.f03e") + file.getPath());
log.warn("{}{}", I18nMessageUtil.get("i18n.file_or_directory_not_found.f03e"), file.getPath());
return false;
}
AgentFileTailWatcher<Session> agentFileTailWatcher = CONCURRENT_HASH_MAP.computeIfAbsent(file, s -> {

View File

@ -136,6 +136,9 @@ public abstract class BaseFileTailWatcher<T extends AutoCloseable> {
public void start() {
//this.tailWatcherRun = new FileTailWatcherRun(logFile, this::sendAll);
if (this.tailer != null) {
this.tailer.stop();
}
this.tailer = new Tailer(logFile, charset, line -> {
limitQueue.offer(line);
this.sendAll(line);