From e35c4d580007f28db90d90b2726c0bbbc943b605 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Mon, 26 Oct 2015 12:03:46 -0400 Subject: [PATCH] SessionCloseOnGCTest#testCloseOneSessionOnGC avoiding intermittent failure - small improvement --- .../client/SessionCloseOnGCTest.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 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 13b73df223..a5d8e1c11c 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 @@ -181,20 +181,14 @@ public class SessionCloseOnGCTest extends ActiveMQTestBase { public void testCloseOneSessionOnGC() throws Exception { ClientSessionFactoryImpl sf = (ClientSessionFactoryImpl) locator.createSessionFactory(); - ClientSession session = sf.createSession(false, true, true); + { + ClientSession session = sf.createSession(false, true, true); - WeakReference wses = new WeakReference(session); + Assert.assertEquals(1, server.getRemotingService().getConnections().size()); + } - Assert.assertEquals(1, server.getRemotingService().getConnections().size()); - - session = null; - - ActiveMQTestBase.checkWeakReferences(wses); - - for (int i = 0; i < 100 && sf.numSessions() != 0; i++) { - System.gc(); - System.runFinalization(); - Thread.sleep(100); + for (int i = 0; i < 1000 && sf.numSessions() != 0; i++) { + forceGC(); } Assert.assertEquals(0, sf.numSessions());