INT-2620 Fix Race Condition in Failover Tests

Sporadic test failures (fairly consistently on Mac).

Problem was some tests sent a message to a client socket before the
close notification had been received.

Wait for client connection to close rather than waiting for the
server to stop.

Also, with NIO, close the channel on accept exception.

Also improve debugging by including a log of new connections
including the id.
This commit is contained in:
Gary Russell
2012-06-26 08:00:33 -04:00
parent 7d6b5850f5
commit bf4005a92c
4 changed files with 42 additions and 12 deletions

View File

@@ -335,7 +335,7 @@ public class FailoverClientConnectionFactoryTests {
Message<?> replyMessage = replyChannel.receive(10000);
assertNotNull(replyMessage);
server1.stop();
TestingUtilities.waitStopListening(server1, null);
TestingUtilities.waitUntilFactoryHasThisNumberOfConnections(client1, 0);
outGateway.handleMessage(message);
socket = getSocket(client2);
port2 = socket.getLocalPort();
@@ -343,6 +343,7 @@ public class FailoverClientConnectionFactoryTests {
replyMessage = replyChannel.receive(10000);
assertNotNull(replyMessage);
gateway2.stop();
outGateway.stop();
}
private Socket getSocket(AbstractClientConnectionFactory client) throws Exception {