Skip to content

Commit 0675fdf

Browse files
committed
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
1 parent 7795496 commit 0675fdf

File tree

1 file changed

+2
-14
lines changed
  • spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl

1 file changed

+2
-14
lines changed

spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java

+2-14
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@
4040
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4141

4242
import io.netty.buffer.PooledByteBufAllocator;
43-
import io.netty.util.NetUtil;
4443
import io.rsocket.frame.decoder.PayloadDecoder;
45-
import io.rsocket.transport.netty.client.TcpClientTransport;
4644
import reactor.core.publisher.Flux;
4745
import reactor.core.publisher.Mono;
48-
import reactor.netty.tcp.InetSocketAddressUtil;
49-
import reactor.netty.tcp.TcpClient;
5046

5147
/**
5248
* @author Artem Bilan
@@ -87,18 +83,10 @@ public ServerRSocketConnector serverRSocketConnector() {
8783
return serverRSocketConnector;
8884
}
8985

90-
9186
@Bean
9287
public ClientRSocketConnector clientRSocketConnector(ServerRSocketConnector serverRSocketConnector) {
93-
ClientRSocketConnector clientRSocketConnector =
94-
new ClientRSocketConnector(
95-
TcpClientTransport.create(
96-
TcpClient.create()
97-
.addressSupplier(() ->
98-
InetSocketAddressUtil.createUnresolved(
99-
NetUtil.LOCALHOST.getHostAddress(),
100-
serverRSocketConnector.getBoundPort().block()))
101-
));
88+
int port = serverRSocketConnector.getBoundPort().block();
89+
ClientRSocketConnector clientRSocketConnector = new ClientRSocketConnector("localhost", port);
10290
clientRSocketConnector.setFactoryConfigurer((factory) -> factory.frameDecoder(PayloadDecoder.ZERO_COPY));
10391
clientRSocketConnector.setRSocketStrategies(rsocketStrategies());
10492
clientRSocketConnector.setAutoStartup(false);

0 commit comments

Comments
 (0)