From 734eae72a7fdfe0da0e97372fefa25c70a89cdf0 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 29 Nov 2012 21:28:27 -0500 Subject: [PATCH] INT-2839 Fix Test Race Condition A secondary part of the new gateway test was to ensure we reused the cached connection. However, there was a race condition in that the connection may not yet have been returned to the pool by the reader thread that received the response. --- .../ip/tcp/connection/CachingClientConnectionFactoryTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactoryTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactoryTests.java index 2601ad8276..b065cb17ee 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactoryTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/CachingClientConnectionFactoryTests.java @@ -320,6 +320,9 @@ public class CachingClientConnectionFactoryTests { assertNotNull(m); assertEquals("foo:" + "Hello, world!", new String((byte[]) m.getPayload())); + // wait a short time to allow the connection to be returned to the pool + Thread.sleep(1000); + // assert we use the same connection from the pool toGateway.send(new GenericMessage("Hello, world2!")); m = fromGateway.receive(1000);