SessionCloseOnGCTest#testCloseOneSessionOnGC avoiding intermittent failure - small improvement

This commit is contained in:
Clebert Suconic 2015-10-26 12:03:46 -04:00
parent bd946d2ce8
commit e35c4d5800
1 changed files with 6 additions and 12 deletions

View File

@ -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);
WeakReference<ClientSession> wses = new WeakReference<ClientSession>(session);
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());