You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by di...@apache.org on 2023/07/10 14:11:06 UTC

[kafka] 06/08: MINOR: Add more information in assertion failure for non daemon threads (#13858)

This is an automated email from the ASF dual-hosted git repository.

divijv pushed a commit to branch 3.5
in repository https://gitbox.apache.org/repos/asf/kafka.git

commit b7a754477f0c89d4c36e97cdbf233d7f854574c5
Author: Divij Vaidya <di...@amazon.com>
AuthorDate: Fri Jun 16 15:17:57 2023 +0200

    MINOR: Add more information in assertion failure for non daemon threads (#13858)
    
    Reviewers: Luke Chen <sh...@gmail.com>
---
 core/src/test/scala/unit/kafka/utils/TestUtils.scala | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/core/src/test/scala/unit/kafka/utils/TestUtils.scala b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
index a499ac38344..3b1830da9e8 100755
--- a/core/src/test/scala/unit/kafka/utils/TestUtils.scala
+++ b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
@@ -1337,10 +1337,12 @@ object TestUtils extends Logging {
   // Note: Call this method in the test itself, rather than the @AfterEach method.
   // Because of the assert, if assertNoNonDaemonThreads fails, nothing after would be executed.
   def assertNoNonDaemonThreads(threadNamePrefix: String): Unit = {
-    val threadCount = Thread.getAllStackTraces.keySet.asScala.count { t =>
+    val nonDaemonThreads = Thread.getAllStackTraces.keySet.asScala.filter { t =>
       !t.isDaemon && t.isAlive && t.getName.startsWith(threadNamePrefix)
     }
-    assertEquals(0, threadCount)
+
+    val threadCount = nonDaemonThreads.size
+    assertEquals(0, threadCount, s"Found unexpected $threadCount NonDaemon threads=${nonDaemonThreads.map(t => t.getName).mkString(", ")}")
   }
 
   def allThreadStackTraces(): String = {