diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/S3ATestUtils.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/S3ATestUtils.java index 592c4be907d..c8e0d368793 100644 --- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/S3ATestUtils.java +++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/S3ATestUtils.java @@ -1396,13 +1396,17 @@ public final class S3ATestUtils { } /** - * Get a set containing the names of all active threads. + * Get a set containing the names of all active threads, + * stripping out all test runner threads. * @return the current set of threads. */ public static Set getCurrentThreadNames() { - return Thread.getAllStackTraces().keySet() + TreeSet threads = Thread.getAllStackTraces().keySet() .stream() .map(Thread::getName) + .filter(n -> n.startsWith("JUnit")) + .filter(n -> n.startsWith("surefire")) .collect(Collectors.toCollection(TreeSet::new)); + return threads; } }