Skip to content

Commit 90a2f4b

Browse files
authored
GH-3509: Fix if test in previous commit
Caused interceptor to be skipped. **cherry-pick to 5.4.x** * Fix race in new tests * Remove overloaded conn id in test interceptor.
1 parent 482673a commit 90a2f4b

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpNetClientConnectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ protected TcpConnectionSupport buildNewConnection() {
5757
this.tcpNetConnectionSupport.createNewConnection(socket, false, isLookupHost(),
5858
getApplicationEventPublisher(), getComponentName());
5959
TcpConnectionSupport wrapped = wrapConnection(connection);
60-
if (wrapped.equals(connection)) {
60+
if (!wrapped.equals(connection)) {
6161
connection.setSenders(getSenders());
6262
connection = wrapped;
6363
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
2020
import static org.assertj.core.api.Assertions.fail;
21+
import static org.awaitility.Awaitility.await;
2122
import static org.mockito.Mockito.mock;
2223

2324
import java.io.IOException;
@@ -30,7 +31,6 @@
3031
import java.util.ArrayList;
3132
import java.util.HashSet;
3233
import java.util.List;
33-
import java.util.Map;
3434
import java.util.Set;
3535
import java.util.TreeSet;
3636
import java.util.concurrent.CountDownLatch;
@@ -73,7 +73,6 @@
7373
import org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer;
7474
import org.springframework.integration.ip.util.TestingUtilities;
7575
import org.springframework.integration.support.MessageBuilder;
76-
import org.springframework.integration.test.util.TestUtils;
7776
import org.springframework.messaging.Message;
7877
import org.springframework.messaging.MessageChannel;
7978
import org.springframework.messaging.MessagingException;
@@ -1230,7 +1229,7 @@ public void testInterceptedConnection() throws Exception {
12301229
socket.close();
12311230
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
12321231
assertThat(connection.get()).isInstanceOf(HelloWorldInterceptor.class);
1233-
assertThat(TestUtils.getPropertyValue(handler, "connections", Map.class)).isEmpty();
1232+
await().untilAsserted(() -> handler.getConnections().isEmpty());
12341233
scf.stop();
12351234
}
12361235

@@ -1259,7 +1258,7 @@ public void testInterceptedCleanup() throws Exception {
12591258
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
12601259
socket.close();
12611260
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
1262-
assertThat(handler.getConnections().isEmpty()).isTrue();
1261+
await().untilAsserted(() -> handler.getConnections().isEmpty());
12631262
scf.stop();
12641263
}
12651264

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)