Skip to content

Commit ec8a747

Browse files
gigermocasartembilan
authored andcommitted
GH-3509: Fix regression in TcpNetServerConnectionFactory
Related to #3509 * Fix intercepted connection cleanup tests * Add missing logic to call `setSenders()` on wrapped connection **Cherry-pick to `5.4.x`**
1 parent 9bab07d commit ec8a747

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
*
3636
* @author Gary Russell
3737
* @author Artem Bilan
38+
* @author Mário Dias
3839
*
3940
* @since 2.0
4041
*
@@ -180,7 +181,11 @@ private void acceptConnectionAndExecute() throws IOException {
180181
setSocketAttributes(socket);
181182
TcpConnectionSupport connection = this.tcpNetConnectionSupport.createNewConnection(socket, true,
182183
isLookupHost(), getApplicationEventPublisher(), getComponentName());
183-
connection = wrapConnection(connection);
184+
TcpConnectionSupport wrapped = wrapConnection(connection);
185+
if (!wrapped.equals(connection)) {
186+
connection.setSenders(getSenders());
187+
connection = wrapped;
188+
}
184189
initializeConnection(connection, socket);
185190
getTaskExecutor().execute(connection);
186191
harvestClosedConnections();

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,6 @@ public void testConnectionException() throws Exception {
11991199
}
12001200
}
12011201

1202-
@SuppressWarnings("unchecked")
12031202
@Test
12041203
public void testInterceptedConnection() throws Exception {
12051204
final CountDownLatch latch = new CountDownLatch(1);
@@ -1229,7 +1228,7 @@ public void testInterceptedConnection() throws Exception {
12291228
socket.close();
12301229
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
12311230
assertThat(connection.get()).isInstanceOf(HelloWorldInterceptor.class);
1232-
await().untilAsserted(() -> handler.getConnections().isEmpty());
1231+
await().untilAsserted(() -> assertThat(handler.getConnections()).isEmpty());
12331232
scf.stop();
12341233
}
12351234

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

0 commit comments

Comments
 (0)