lianetm commented on code in PR #19927:
URL: https://github.com/apache/kafka/pull/19927#discussion_r2356554041


##########
clients/src/test/java/org/apache/kafka/test/TestUtils.java:
##########
@@ -171,12 +170,9 @@ public static MetadataSnapshot metadataSnapshotWith(final 
int nodes, final Map<S
      *
      * @throws AssertionError If any thread with the specified name prefix and 
daemon status is found and is alive.
      */
-    public static void assertNoLeakedThreadsWithNameAndDaemonStatus(String 
threadName, boolean isDaemon) {
-        List<Thread> threads = Thread.getAllStackTraces().keySet().stream()
-                .filter(t -> t.isDaemon() == isDaemon && t.isAlive() && 
t.getName().startsWith(threadName))
-                .collect(Collectors.toList());
-        int threadCount = threads.size();
-        assertEquals(0, threadCount);
+    public static void assertNoLeakedThreadsWithNameAndDaemonStatus(String 
threadName, boolean isDaemon) throws InterruptedException {
+        waitForCondition(() -> Thread.getAllStackTraces().keySet().stream()
+                .noneMatch(t -> t.isDaemon() == isDaemon && t.isAlive() && 
t.getName().startsWith(threadName)), String.format("Thread with prefix:[%s] is 
alive", threadName));

Review Comment:
   nit: seems clear to refer to the leak in the error message. Would be nice to 
be consistent with the similar validation we have on the new test infra: 
https://github.com/apache/kafka/blob/9a32a71e76da604f3e84734737fdf5e3fe9823f6/test-common/test-common-runtime/src/main/java/org/apache/kafka/common/test/junit/ClusterTestExtensions.java#L184
 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to