diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpClient.java b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpClient.java index 0fa331ba138..a595de3a47e 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpClient.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpClient.java @@ -58,6 +58,7 @@ import java.util.concurrent.TimeUnit; import static io.netty.handler.codec.http.HttpHeaderNames.HOST; import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; +import static org.junit.Assert.fail; /** * Tiny helper to send http requests over netty. @@ -145,7 +146,9 @@ class Netty4HttpClient implements Closeable { for (HttpRequest request : requests) { channelFuture.channel().writeAndFlush(request); } - latch.await(30, TimeUnit.SECONDS); + if (latch.await(30L, TimeUnit.SECONDS) == false) { + fail("Failed to get all expected responses."); + } } finally { if (channelFuture != null) { diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpClient.java b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpClient.java index 5546a8578ab..785b6ea5970 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpClient.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/http/nio/NioHttpClient.java @@ -71,6 +71,7 @@ import java.util.function.Consumer; import static io.netty.handler.codec.http.HttpHeaderNames.HOST; import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory; +import static org.junit.Assert.fail; /** * Tiny helper to send http requests over nio. @@ -136,7 +137,9 @@ class NioHttpClient implements Closeable { for (HttpRequest request : requests) { nioSocketChannel.getContext().sendMessage(request, (v, e) -> {}); } - latch.await(30, TimeUnit.SECONDS); + if (latch.await(30L, TimeUnit.SECONDS) == false) { + fail("Failed to get all expected responses."); + } } catch (IOException e) { throw new UncheckedIOException(e);