From bd946d2ce8defe7bf79d66c0690940f7b423917b Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 26 Oct 2015 11:10:48 -0400 Subject: [PATCH] SessionCloseOnGCTest#testCloseOneSessionOnGC avoiding intermittent failure --- .../tests/integration/client/SessionCloseOnGCTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseOnGCTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseOnGCTest.java index 080322b973..13b73df223 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseOnGCTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/client/SessionCloseOnGCTest.java @@ -16,6 +16,8 @@ */ package org.apache.activemq.artemis.tests.integration.client; +import java.lang.ref.WeakReference; + import org.apache.activemq.artemis.api.core.client.ClientSession; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ServerLocator; @@ -26,8 +28,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import java.lang.ref.WeakReference; - public class SessionCloseOnGCTest extends ActiveMQTestBase { private ActiveMQServer server; @@ -191,6 +191,12 @@ public class SessionCloseOnGCTest extends ActiveMQTestBase { ActiveMQTestBase.checkWeakReferences(wses); + for (int i = 0; i < 100 && sf.numSessions() != 0; i++) { + System.gc(); + System.runFinalization(); + Thread.sleep(100); + } + Assert.assertEquals(0, sf.numSessions()); Assert.assertEquals(1, sf.numConnections()); Assert.assertEquals(1, server.getRemotingService().getConnections().size());