From ae5ba48dfc7cb59c0513489a3ed67825d1f6619b Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Fri, 26 Jan 2018 11:09:59 +0000 Subject: [PATCH] Java client: Avoid throwing a TimeoutException after the operation was successful (#24069) --- .../org/elasticsearch/client/RestClientBuilder.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/rest/src/main/java/org/elasticsearch/client/RestClientBuilder.java b/client/rest/src/main/java/org/elasticsearch/client/RestClientBuilder.java index 286ed7dd53910..90a19f7ee24bd 100644 --- a/client/rest/src/main/java/org/elasticsearch/client/RestClientBuilder.java +++ b/client/rest/src/main/java/org/elasticsearch/client/RestClientBuilder.java @@ -43,7 +43,13 @@ public final class RestClientBuilder { public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 1000; public static final int DEFAULT_SOCKET_TIMEOUT_MILLIS = 30000; public static final int DEFAULT_MAX_RETRY_TIMEOUT_MILLIS = DEFAULT_SOCKET_TIMEOUT_MILLIS; - public static final int DEFAULT_CONNECTION_REQUEST_TIMEOUT_MILLIS = 500; + + /** + * Disabled as Apache Http Async Client would otherwise throw TimeoutException(s) even when returning connections to + * the pool, after having done performed an RPC successfully. + * See also https://github.com/elastic/elasticsearch/issues/24069 + */ + public static final int DEFAULT_CONNECTION_REQUEST_TIMEOUT_MILLIS = 0; public static final int DEFAULT_MAX_CONN_PER_ROUTE = 10; public static final int DEFAULT_MAX_CONN_TOTAL = 30; @@ -193,7 +199,7 @@ public CloseableHttpAsyncClient run() { } private CloseableHttpAsyncClient createHttpClient() { - //default timeouts are all infinite + //default timeouts are all infinite, except the RequestTimeout which is explicitly disabled. RequestConfig.Builder requestConfigBuilder = RequestConfig.custom() .setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS) .setSocketTimeout(DEFAULT_SOCKET_TIMEOUT_MILLIS)