You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2022/10/13 13:39:16 UTC
[tika] branch main updated: TIKA-3877 -- fix potential thread leak in FileSystemStatusReporter
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new 79c4aef6b TIKA-3877 -- fix potential thread leak in FileSystemStatusReporter
79c4aef6b is described below
commit 79c4aef6ba8f31eca3e740216a5d8fa09f0e3895
Author: tballison <ta...@apache.org>
AuthorDate: Thu Oct 13 09:39:07 2022 -0400
TIKA-3877 -- fix potential thread leak in FileSystemStatusReporter
---
.../org/apache/tika/pipes/reporters/fs/FileSystemStatusReporter.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tika-pipes/tika-pipes-reporters/tika-pipes-reporter-fs-status/src/main/java/org/apache/tika/pipes/reporters/fs/FileSystemStatusReporter.java b/tika-pipes/tika-pipes-reporters/tika-pipes-reporter-fs-status/src/main/java/org/apache/tika/pipes/reporters/fs/FileSystemStatusReporter.java
index cee42ed36..a28c3040d 100644
--- a/tika-pipes/tika-pipes-reporters/tika-pipes-reporter-fs-status/src/main/java/org/apache/tika/pipes/reporters/fs/FileSystemStatusReporter.java
+++ b/tika-pipes/tika-pipes-reporters/tika-pipes-reporter-fs-status/src/main/java/org/apache/tika/pipes/reporters/fs/FileSystemStatusReporter.java
@@ -85,10 +85,11 @@ public class FileSystemStatusReporter extends PipesReporter
}
});
+ reporterThread.setDaemon(true);
reporterThread.start();
}
- private static void report(Path statusFile, ObjectMapper objectMapper,
+ private static synchronized void report(Path statusFile, ObjectMapper objectMapper,
ConcurrentHashMap<PipesResult.STATUS, LongAdder> counts) {
try (Writer writer = Files.newBufferedWriter(statusFile, StandardCharsets.UTF_8)) {
objectMapper.writeValue(writer, counts);
@@ -115,6 +116,7 @@ public class FileSystemStatusReporter extends PipesReporter
@Override
public void close() throws IOException {
LOG.debug("finishing and writing last report");
+ reporterThread.interrupt();
report(statusFile, objectMapper, counts);
}