From 413d66018e79240fc1c824c0ed867eebc387107c Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Thu, 3 Feb 2022 09:22:33 -0500 Subject: [PATCH] GH-3713: Fix Race In Test --- .../integration/ip/tcp/connection/TcpSenderTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpSenderTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpSenderTests.java index c2b980ea2b..cec458aba9 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpSenderTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpSenderTests.java @@ -112,6 +112,7 @@ public class TcpSenderTests { } chain.setInterceptor(new InterceptorFactory(), new InterceptorFactory(), new InterceptorFactory()); client.setInterceptorFactoryChain(chain); + CountDownLatch firstClosed = new CountDownLatch(1); client.registerSender(new TcpSender() { @Override @@ -124,6 +125,7 @@ public class TcpSenderTests { public synchronized void removeDeadConnection(TcpConnection connection) { remOrder.add(99); removes.countDown(); + firstClosed.countDown(); } }); @@ -136,6 +138,7 @@ public class TcpSenderTests { conn = client.getConnection(); assertThat(adds.await(10, TimeUnit.SECONDS)).isTrue(); assertThat(addOrder).containsExactly(1, 2, 3, 99, 4, 5, 6, 99); + assertThat(firstClosed.await(10, TimeUnit.SECONDS)).isTrue(); conn.close(); client.stop(); assertThat(removes.await(10, TimeUnit.SECONDS)).isTrue();