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


##########
core/src/test/java/kafka/test/junit/ClusterTestExtensions.java:
##########
@@ -119,7 +138,21 @@ public Stream<TestTemplateInvocationContext> 
provideTestTemplateInvocationContex
         return generatedContexts.stream();
     }
 
+    @Override
+    public void beforeEach(ExtensionContext context) {
+        detectThreadLeak = DetectThreadLeak.of(thread ->
+                SKIPPED_THREAD_PREFIX.stream().noneMatch(prefix -> 
thread.getName().startsWith(prefix)));
+    }
 
+    @Override
+    public void afterEach(ExtensionContext context) throws 
InterruptedException {
+        if (detectThreadLeak == null) {
+            return;
+        }
+        TestUtils.waitForCondition(() -> 
detectThreadLeak.newThreads().isEmpty(),

Review Comment:
   > I think this waitForCondition will cover up certain thread leaks where the 
test started shutdown of the thread, but didn't call join() to ensure the 
thread was completely stopped. I think these are leaks that would be good to 
find and fix.
   
   that is a great idea, but I guess the related errors will spring up. For 
example, I apply the idea on my local, and Zk SessionTracker show up. We can 
fix them one by one to avoid random failed tests, but that will make this PR 
pending for a while. 
   
   Maybe we can open a jira as follow-up to fix ignored "join()", and 
eventually we can remove the waiting from thread leak detection.
   
   @gharris1727 WDYT?
   



-- 
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