diff --git a/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java b/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java index 98ac0ae2c2776..0757730423688 100644 --- a/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java +++ b/buildtools/src/main/java/org/apache/pulsar/tests/ThreadLeakDetectorListener.java @@ -177,7 +177,8 @@ private static boolean shouldSkipThread(Thread thread) { return true; } // skip Testcontainers threads - if (thread.getThreadGroup() != null && "testcontainers".equals(thread.getThreadGroup().getName())) { + final ThreadGroup threadGroup = thread.getThreadGroup(); + if (threadGroup != null && "testcontainers".equals(threadGroup.getName())) { return true; } String threadName = thread.getName();