activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject activemq-artemis git commit: Improving Thread checker API
Date Fri, 01 Apr 2016 02:37:51 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/refactor-openwire fb4456813 -> 3b9dc7a63


Improving Thread checker API


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/3b9dc7a6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/3b9dc7a6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/3b9dc7a6

Branch: refs/heads/refactor-openwire
Commit: 3b9dc7a631460d8e6ddcd6554a0b5b9fb07bd7fd
Parents: fb44568
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Thu Mar 31 22:33:15 2016 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Mar 31 22:33:19 2016 -0400

----------------------------------------------------------------------
 .../artemis/tests/util/ThreadLeakCheckRule.java | 27 ++++++++++----------
 .../transport/SoWriteTimeoutClientTest.java     |  4 +--
 2 files changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3b9dc7a6/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
index 232d3ae..3b53d53 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ThreadLeakCheckRule.java
@@ -28,7 +28,7 @@ import org.junit.rules.ExternalResource;
  * This is useful to make sure you won't have leaking threads between tests
  */
 public class ThreadLeakCheckRule extends ExternalResource {
-   private static Set<String> extraThreads = new HashSet<String>();
+   private static Set<String> knownThreads = new HashSet<String>();
 
    boolean enabled = true;
 
@@ -97,10 +97,12 @@ public class ThreadLeakCheckRule extends ExternalResource {
 
    }
 
-   public static void addExtraThreads(String... threads) {
-      for (String th : threads) {
-         extraThreads.add(th);
-      }
+   public static void removeKownThread(String name) {
+      knownThreads.remove(name);
+   }
+
+   public static void addKownThread(String name) {
+      knownThreads.add(name);
    }
 
    private boolean checkThread() {
@@ -191,21 +193,20 @@ public class ThreadLeakCheckRule extends ExternalResource {
          // Static workers used by MQTT client.
          return true;
       }
-      else if (extraThreads.contains(threadName)) {
-         return true;
-      }
       else {
          for (StackTraceElement element : thread.getStackTrace()) {
             if (element.getClassName().contains("org.jboss.byteman.agent.TransformListener"))
{
                return true;
             }
          }
-         return false;
-      }
-   }
 
+         for (String known: knownThreads) {
+            if (threadName.contains(known)) {
+               return true;
+            }
+         }
 
-   public static void clearExtraThreads() {
-      extraThreads.clear();
+         return false;
+      }
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/3b9dc7a6/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
----------------------------------------------------------------------
diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
index 48c36cf..0b62b31 100644
--- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
+++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/SoWriteTimeoutClientTest.java
@@ -54,12 +54,12 @@ public class SoWriteTimeoutClientTest extends OpenwireArtemisBaseTest
{
    @BeforeClass
    public static void beforeTest() throws Exception {
       //this thread keeps alive in original test too. Exclude it.
-      ThreadLeakCheckRule.addExtraThreads("WriteTimeoutFilter-Timeout-1");
+      ThreadLeakCheckRule.addKownThread("WriteTimeoutFilter-Timeout");
    }
 
    @AfterClass
    public static void afterTest() throws Exception {
-      ThreadLeakCheckRule.clearExtraThreads();
+      ThreadLeakCheckRule.removeKownThread("WriteTimeoutFilter-Timeout");
    }
 
    @Before


Mime
View raw message