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.
This commit is contained in:
Gary Russell
2021-03-17 18:33:34 -04:00
committed by GitHub
parent 482673a159
commit 90a2f4bff1
3 changed files with 5 additions and 6 deletions

View File

@@ -57,7 +57,7 @@ public class TcpNetClientConnectionFactory extends
this.tcpNetConnectionSupport.createNewConnection(socket, false, isLookupHost(),
getApplicationEventPublisher(), getComponentName());
TcpConnectionSupport wrapped = wrapConnection(connection);
if (wrapped.equals(connection)) {
if (!wrapped.equals(connection)) {
connection.setSenders(getSenders());
connection = wrapped;
}

View File

@@ -18,6 +18,7 @@ package org.springframework.integration.ip.tcp;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.awaitility.Awaitility.await;
import static org.mockito.Mockito.mock;
import java.io.IOException;
@@ -30,7 +31,6 @@ import java.net.SocketException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch;
@@ -73,7 +73,6 @@ import org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSe
import org.springframework.integration.ip.tcp.serializer.ByteArrayStxEtxSerializer;
import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
@@ -1230,7 +1229,7 @@ public class TcpSendingMessageHandlerTests extends AbstractTcpChannelAdapterTest
socket.close();
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(connection.get()).isInstanceOf(HelloWorldInterceptor.class);
assertThat(TestUtils.getPropertyValue(handler, "connections", Map.class)).isEmpty();
await().untilAsserted(() -> handler.getConnections().isEmpty());
scf.stop();
}
@@ -1259,7 +1258,7 @@ public class TcpSendingMessageHandlerTests extends AbstractTcpChannelAdapterTest
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
socket.close();
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
assertThat(handler.getConnections().isEmpty()).isTrue();
await().untilAsserted(() -> handler.getConnections().isEmpty());
scf.stop();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.