You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2015/10/26 16:06:07 UTC
activemq-artemis git commit: Improving forceGC method on
ActiveMQTestBase
Repository: activemq-artemis
Updated Branches:
refs/heads/master 8c6ba443a -> 15b8b8138
Improving forceGC method on ActiveMQTestBase
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/15b8b813
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/15b8b813
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/15b8b813
Branch: refs/heads/master
Commit: 15b8b8138bcb3148c5fd64823d2c2b5170a661cc
Parents: 8c6ba44
Author: Clebert Suconic <cl...@apache.org>
Authored: Mon Oct 26 11:02:53 2015 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Mon Oct 26 11:02:53 2015 -0400
----------------------------------------------------------------------
.../activemq/artemis/tests/util/ActiveMQTestBase.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15b8b813/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 7e358a9..5556c4e 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
@@ -525,14 +525,15 @@ public abstract class ActiveMQTestBase extends Assert {
public static void forceGC() {
log.info("#test forceGC");
- AtomicInteger finalized = new AtomicInteger(0);
+ CountDownLatch finalized = new CountDownLatch(1);
WeakReference<DumbReference> dumbReference = new WeakReference<>(new DumbReference(finalized));
+
// A loop that will wait GC, using the minimal time as possible
- while (!(dumbReference.get() == null && finalized.get() == 1)) {
+ while (!(dumbReference.get() == null && finalized.getCount() == 0)) {
System.gc();
System.runFinalization();
try {
- Thread.sleep(100);
+ finalized.await(100, TimeUnit.MILLISECONDS);
}
catch (InterruptedException e) {
}
@@ -2540,15 +2541,14 @@ public abstract class ActiveMQTestBase extends Assert {
protected static class DumbReference {
- private AtomicInteger finalized;
+ private CountDownLatch finalized;
- public DumbReference(AtomicInteger finalized) {
+ public DumbReference(CountDownLatch finalized) {
this.finalized = finalized;
}
public void finalize() throws Throwable {
- System.out.println("FINALIZE");
- finalized.incrementAndGet();
+ finalized.countDown();
super.finalize();
}
}