chia7712 commented on code in PR #19927:
URL: https://github.com/apache/kafka/pull/19927#discussion_r2365919243
##########
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 leak detected: ",
threadName));
Review Comment:
It should be `String.format("Thread leak detected: %s", threadName)`, right?
--
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]