From 0675fdfac95db311bd99a9c32760d539f2f3d6db Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 27 Jun 2019 12:39:48 -0400 Subject: [PATCH] RSocketDslTests: Resolve server port eagerly Looks like there is some connection race condition in Netty on Linux, so we may not be started on server side fully when we try to select a port from the OS * Move local port resolution and, therefore, RSocket server start into the earlier phase before creating a client --- .../integration/rsocket/dsl/RSocketDslTests.java | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java b/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java index a65e679149..770fb43b57 100644 --- a/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java +++ b/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java @@ -40,13 +40,9 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import io.netty.buffer.PooledByteBufAllocator; -import io.netty.util.NetUtil; import io.rsocket.frame.decoder.PayloadDecoder; -import io.rsocket.transport.netty.client.TcpClientTransport; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; -import reactor.netty.tcp.InetSocketAddressUtil; -import reactor.netty.tcp.TcpClient; /** * @author Artem Bilan @@ -87,18 +83,10 @@ public class RSocketDslTests { return serverRSocketConnector; } - @Bean public ClientRSocketConnector clientRSocketConnector(ServerRSocketConnector serverRSocketConnector) { - ClientRSocketConnector clientRSocketConnector = - new ClientRSocketConnector( - TcpClientTransport.create( - TcpClient.create() - .addressSupplier(() -> - InetSocketAddressUtil.createUnresolved( - NetUtil.LOCALHOST.getHostAddress(), - serverRSocketConnector.getBoundPort().block())) - )); + int port = serverRSocketConnector.getBoundPort().block(); + ClientRSocketConnector clientRSocketConnector = new ClientRSocketConnector("localhost", port); clientRSocketConnector.setFactoryConfigurer((factory) -> factory.frameDecoder(PayloadDecoder.ZERO_COPY)); clientRSocketConnector.setRSocketStrategies(rsocketStrategies()); clientRSocketConnector.setAutoStartup(false);