FrankYang0529 commented on code in PR #16499:
URL: https://github.com/apache/kafka/pull/16499#discussion_r1671369797


##########
core/src/test/java/kafka/test/junit/ClusterTestExtensions.java:
##########
@@ -119,7 +124,24 @@ public Stream<TestTemplateInvocationContext> 
provideTestTemplateInvocationContex
         return generatedContexts.stream();
     }
 
+    @Override
+    public void beforeEach(ExtensionContext context) {
+        detectThreadLeak = DetectThreadLeak.of(thread -> {
+            String name = thread.getName();
+            return !name.startsWith("metrics-meter-tick-thread") &&
+                    !name.startsWith("scala-") &&
+                    !name.startsWith("ForkJoinPool") &&
+                    !name.startsWith("junit-") &&
+                    !name.startsWith("Attach Listener") &&
+                    !name.startsWith("process reaper");
+        });
+    }
 
+    @Override
+    public void afterEach(ExtensionContext context) throws 
InterruptedException {
+        TestUtils.waitForCondition(() -> 
detectThreadLeak.newThreads().isEmpty(),
+                "Thread leak detected: " + detectThreadLeak.newThreads());

Review Comment:
   Yeah, `Thread#toString` already show `getName` in it. I change this line to 
join each thread name. Hope it's more clear. Thanks.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to