From b495a8632050ccce0ab257bf9a232b78b84b4ebf Mon Sep 17 00:00:00 2001 From: Dawid Weiss Date: Sat, 14 Dec 2024 20:05:52 +0100 Subject: [PATCH] Ignore the default ForkJoinPool's system threads in thread leak detection #14066 --- .../lucene/tests/util/QuickPatchThreadsFilter.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/QuickPatchThreadsFilter.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/QuickPatchThreadsFilter.java index 480c86438f3..191d5a49f70 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/QuickPatchThreadsFilter.java +++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/QuickPatchThreadsFilter.java @@ -19,6 +19,8 @@ package org.apache.lucene.tests.util; import com.carrotsearch.randomizedtesting.ThreadFilter; import org.apache.lucene.util.Constants; +import java.util.concurrent.ForkJoinWorkerThread; + /** Last minute patches. */ public class QuickPatchThreadsFilter implements ThreadFilter { static final boolean isJ9; @@ -42,6 +44,15 @@ public class QuickPatchThreadsFilter implements ThreadFilter { return true; } } + + if (t instanceof ForkJoinWorkerThread + && t.getName().startsWith("ForkJoinPool.commonPool-worker") + && t.isDaemon()) { + // GH-14066: filter out common pool's worker threads. Assume they have completed + // all background tasks and are idle. + return true; + } + return false; } }