Skip to content

Commit

Permalink
Use CountDownLatch for the test
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Mar 13, 2019
1 parent 027e220 commit 42f0b52
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/test/java/reactor/netty/tcp/TcpClientTests.java
Expand Up @@ -836,15 +836,15 @@ private void doTestIssue600(boolean withLoop) {
}

@Test
public void testRetryOnDifferentAddress() {
public void testRetryOnDifferentAddress() throws Exception {
DisposableServer server =
TcpServer.create()
.port(0)
.wiretap(true)
.handle((req, res) -> res.sendString(Mono.just("test")))
.bindNow();

final AtomicBoolean connected = new AtomicBoolean(false);
final CountDownLatch latch = new CountDownLatch(1);

Supplier<SocketAddress> addressSupplier = new Supplier<SocketAddress>() {
int i = 2;
Expand All @@ -858,7 +858,7 @@ public SocketAddress get() {
Connection conn =
TcpClient.create()
.addressSupplier(addressSupplier)
.doOnConnected(connection -> connected.set(true))
.doOnConnected(connection -> latch.countDown())
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 100)
.handle((in, out) -> Mono.never())
.wiretap(true)
Expand All @@ -867,7 +867,7 @@ public SocketAddress get() {
.block(Duration.ofSeconds(30));
assertNotNull(conn);

assertTrue(connected.get());
assertTrue(latch.await(30, TimeUnit.SECONDS));

conn.disposeNow();
server.disposeNow();
Expand Down

0 comments on commit 42f0b52

Please sign in to comment.