activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/5] activemq-artemis git commit: adding timeout verification
Date Tue, 19 Jan 2016 22:43:31 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master c58209f03 -> 2d4654ca2


adding timeout verification

Some VMs (IBM) can eventually ignore the System.gc call.
Adding some mitigation when that happens here


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

Branch: refs/heads/master
Commit: 17a443b1f0b0ed9d69b043ca6c5535480ba90aec
Parents: c58209f
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Mon Jan 18 12:31:52 2016 -0500
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Jan 19 17:20:49 2016 -0500

----------------------------------------------------------------------
 .../artemis/tests/util/ActiveMQTestBase.java    | 22 ++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/17a443b1/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
index 5d76df8..5e610d5 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
@@ -499,13 +499,22 @@ public abstract class ActiveMQTestBase extends Assert {
       }
    }
 
+   private static int failedGCCalls = 0;
+
    public static void forceGC() {
+
+      if (failedGCCalls >= 10) {
+         log.info("ignoring forceGC call since it seems System.gc is not working anyways");
+         return;
+      }
       log.info("#test forceGC");
       CountDownLatch finalized = new CountDownLatch(1);
       WeakReference<DumbReference> dumbReference = new WeakReference<>(new DumbReference(finalized));
 
+      long timeout = System.currentTimeMillis() + 1000;
+
       // A loop that will wait GC, using the minimal time as possible
-      while (!(dumbReference.get() == null && finalized.getCount() == 0)) {
+      while (!(dumbReference.get() == null && finalized.getCount() == 0) &&
System.currentTimeMillis() < timeout) {
          System.gc();
          System.runFinalization();
          try {
@@ -514,7 +523,16 @@ public abstract class ActiveMQTestBase extends Assert {
          catch (InterruptedException e) {
          }
       }
-      log.info("#test forceGC Done");
+
+      if (dumbReference.get() != null) {
+         failedGCCalls++;
+         log.info("It seems that GC is disabled at your VM");
+      }
+      else {
+         // a success would reset the count
+         failedGCCalls = 0;
+      }
+      log.info("#test forceGC Done ");
    }
 
    public static void forceGC(final Reference<?> ref, final long timeout) {


Mime
View raw message