You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "cbornet (via GitHub)" <gi...@apache.org> on 2023/11/01 23:00:46 UTC

Re: [PR] [improve][ci] Improve thread leak detection by ignoring more Testcontainers threads [pulsar]

cbornet commented on code in PR #21499:
URL: https://github.com/apache/pulsar/pull/21499#discussion_r1379412751


##########
buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java:
##########
@@ -201,10 +213,32 @@ private static boolean shouldSkipThread(Thread thread) {
             if (threadName.equals("Grizzly-HttpSession-Expirer")) {
                 return true;
             }
+            // Testcontainers AbstractWaitStrategy.EXECUTOR
+            if (threadName.startsWith("testcontainers-wait-")) {
+                return true;
+            }
+        }
+        Runnable target = extractRunnableTarget(thread);
+        if (target != null) {
+            String targetClassName = target.getClass().getName();
+            // ignore threads that contain a Runnable class under org.testcontainers package
+            if (targetClassName.startsWith("org.testcontainers.")) {
+                return true;
+            }
         }
         return false;
     }
 
+    private static Runnable extractRunnableTarget(Thread thread) {

Review Comment:
   NIT: maybe add a comment on why we have to use reflection here.



-- 
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: commits-unsubscribe@pulsar.apache.org

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