Skip to content

Commit 64d5b25

Browse files
committed
GH-3713: Fix Race In Test
1 parent c7f2c17 commit 64d5b25

File tree

1 file changed

+3
-0
lines changed
  • spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection

1 file changed

+3
-0
lines changed

spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/TcpSenderTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public synchronized void removeDeadConnection(TcpConnection connection) {
112112
}
113113
chain.setInterceptor(new InterceptorFactory(), new InterceptorFactory(), new InterceptorFactory());
114114
client.setInterceptorFactoryChain(chain);
115+
CountDownLatch firstClosed = new CountDownLatch(1);
115116
client.registerSender(new TcpSender() {
116117

117118
@Override
@@ -124,6 +125,7 @@ public void addNewConnection(TcpConnection connection) {
124125
public synchronized void removeDeadConnection(TcpConnection connection) {
125126
remOrder.add(99);
126127
removes.countDown();
128+
firstClosed.countDown();
127129
}
128130

129131
});
@@ -136,6 +138,7 @@ public synchronized void removeDeadConnection(TcpConnection connection) {
136138
conn = client.getConnection();
137139
assertThat(adds.await(10, TimeUnit.SECONDS)).isTrue();
138140
assertThat(addOrder).containsExactly(1, 2, 3, 99, 4, 5, 6, 99);
141+
assertThat(firstClosed.await(10, TimeUnit.SECONDS)).isTrue();
139142
conn.close();
140143
client.stop();
141144
assertThat(removes.await(10, TimeUnit.SECONDS)).isTrue();

0 commit comments

Comments
 (0)