Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit f29c998

Browse files
committed
Make RPC test sequential
The test fails randomly, it may be due to a race condition in the RPC client, which may do enough synchronization around the channel.
1 parent aa20a41 commit f29c998

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/test/java/reactor/rabbitmq/RequestReplyTests.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ public void requestReply(String queue, Function<Sender, RpcClient> rpcClientCrea
114114
CountDownLatch latch = new CountDownLatch(nbRequests);
115115
try (RpcClient rpcClient = rpcClientCreator.apply(sender)) {
116116
IntStream.range(0, nbRequests).forEach(i -> {
117-
new Thread(() -> {
118-
String content = "hello " + i;
119-
Mono<Delivery> deliveryMono = rpcClient.rpc(Mono.just(new RpcClient.RpcRequest(content.getBytes())));
120-
assertEquals("*** " + content + " ***", new String(deliveryMono.block().getBody()));
121-
latch.countDown();
122-
}).start();
117+
String content = "hello " + i;
118+
Mono<Delivery> deliveryMono = rpcClient.rpc(Mono.just(new RpcClient.RpcRequest(content.getBytes())));
119+
String received = new String(deliveryMono.block().getBody());
120+
assertEquals("*** " + content + " ***", received);
121+
latch.countDown();
123122
});
123+
assertTrue(latch.await(5, TimeUnit.SECONDS), "All requests should have dealt with by now");
124124
}
125-
assertTrue(latch.await(5, TimeUnit.SECONDS), "All requests should have dealt with by now");
125+
126126
}
127127

128128
private static class TestRpcServer extends RpcServer {

0 commit comments

Comments
 (0)