You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ro...@apache.org on 2022/10/28 10:18:34 UTC

[activemq-artemis] 01/03: ARTEMIS-4076: make test ThreadLeakCheckRule account for differences on Java 19

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

robbie pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 69264aee32795047381ae914348440d9ef385a6f
Author: Robbie Gemmell <ro...@apache.org>
AuthorDate: Thu Oct 27 11:53:23 2022 +0100

    ARTEMIS-4076: make test ThreadLeakCheckRule account for differences on Java 19
    
    In Java 19 the "process reaper" Thread name can change while it is working to also denote the related pid.
    
    Also, the threads are created differently and dont belong to the "system" thread group as before, but the "InnocuousThreadGroup".
    
    Related changes:
    https://github.com/openjdk/jdk/commit/9561b5e041c4cc70319e60953819c521c1e68d6c
    https://github.com/openjdk/jdk/commit/f0282d7def8c043d95e9b86da926b7d45224c31c
---
 .../java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java
index a33dcb87ca..34df25a1a1 100644
--- a/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java
+++ b/artemis-unit-test-support/src/main/java/org/apache/activemq/artemis/utils/ThreadLeakCheckRule.java
@@ -235,7 +235,7 @@ public class ThreadLeakCheckRule extends TestWatcher {
    private boolean isExpectedThread(Thread thread) {
       final String threadName = thread.getName();
       final ThreadGroup group = thread.getThreadGroup();
-      final boolean isSystemThread = group != null && "system".equals(group.getName());
+      final boolean isSystemThread = group != null && ("system".equals(group.getName()) || "InnocuousThreadGroup".equals(group.getName()));
       final String javaVendor = System.getProperty("java.vendor");
 
       if (threadName.contains("SunPKCS11")) {
@@ -244,7 +244,7 @@ public class ThreadLeakCheckRule extends TestWatcher {
          return true;
       } else if (threadName.contains("Attach Listener")) {
          return true;
-      } else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("process reaper")) {
+      } else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.startsWith("process reaper")) {
          return true;
       } else if ((javaVendor.contains("IBM") || isSystemThread) && threadName.equals("ClassCache Reaper")) {
          return true;