Apache Lucene open-source search software
SOLR-13887: Use the default idleTimeout instead of 0 for HTTP2 (#991)
Houston Putman80ed8c281b35
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 57d53823bfb..f7269482469 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -268,6 +268,8 @@ Bug Fixes* SOLR-14219: SOLR-14095 Introduced an issue for rolling restarts (Incompatible Java serialization). This changeFixes the compatibility issue while keeping the functionality in SOLR-14095. (Andy Webb, Tomás Fernández Löbbe)+* SOLR-13887: Use default idleTimeout instead of 0 for HTTP2 requests. (Houston Putman)+Other Changes---------------------diff --git a/solr/solr-ref-guide/src/format-of-solr-xml.adoc b/solr/solr-ref-guide/src/format-of-solr-xml.adocindex 899da945d9e..0190203e640 100644--- a/solr/solr-ref-guide/src/format-of-solr-xml.adoc+++ b/solr/solr-ref-guide/src/format-of-solr-xml.adoc@@ -40,8 +40,8 @@ You can find `solr.xml` in your `$SOLR_HOME` directory (usually `server/solr`) i<shardHandlerFactory name="shardHandlerFactory"class="HttpShardHandlerFactory">- <int name="socketTimeout">${socketTimeout:0}</int>- <int name="connTimeout">${connTimeout:0}</int>+ <int name="socketTimeout">${socketTimeout:600000}</int>+ <int name="connTimeout">${connTimeout:600000}</int></shardHandlerFactory></solr>@@ -232,15 +232,15 @@ Solr supports variable substitution of JVM system property values in `solr.xml`,Any JVM system properties usually specified using the `-D` flag when starting the JVM, can be used as variables in the `solr.xml` file.-For example, in the `solr.xml` file shown below, the `socketTimeout` and `connTimeout` values are each set to "0". However, if you start Solr using `bin/solr -DsocketTimeout=1000`, the `socketTimeout` option of the `HttpShardHandlerFactory` to be overridden using a value of 1000ms, while the `connTimeout` option will continue to use the default property value of "0".+For example, in the `solr.xml` file shown below, the `socketTimeout` and `connTimeout` values are each set to "60000". However, if you start Solr using `bin/solr -DsocketTimeout=1000`, the `socketTimeout` option of the `HttpShardHandlerFactory` to be overridden using a value of 1000ms, while the `connTimeout` option will continue to use the default property value of "60000".[source,xml]----<solr><shardHandlerFactory name="shardHandlerFactory"class="HttpShardHandlerFactory">- <int name="socketTimeout">${socketTimeout:0}</int>- <int name="connTimeout">${connTimeout:0}</int>+ <int name="socketTimeout">${socketTimeout:60000}</int>+ <int name="connTimeout">${connTimeout:60000}</int></shardHandlerFactory></solr>----diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.javaindex 8c6e546b14d..32eddc1a224 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java@@ -146,7 +146,7 @@ public class Http2SolrClient extends SolrClient {this.serverBaseUrl = serverBaseUrl;}- if (builder.idleTimeout != null) idleTimeout = builder.idleTimeout;+ if (builder.idleTimeout != null && builder.idleTimeout > 0) idleTimeout = builder.idleTimeout;else idleTimeout = HttpClientUtil.DEFAULT_SO_TIMEOUT;if (builder.http2SolrClient == null) {@@ -215,7 +215,7 @@ public class Http2SolrClient extends SolrClient {httpClient.setMaxRequestsQueuedPerDestination(asyncTracker.getMaxRequestsQueuedPerDestination());httpClient.setUserAgentField(new HttpField(HttpHeader.USER_AGENT, AGENT));- if (builder.idleTimeout != null) httpClient.setIdleTimeout(builder.idleTimeout);+ httpClient.setIdleTimeout(idleTimeout);if (builder.connectionTimeout != null) httpClient.setConnectTimeout(builder.connectionTimeout);try {httpClient.start();diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.javaindex 06e4ba9efa0..6462f2c7dcb 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/Http2SolrClientTest.java@@ -183,6 +183,17 @@ public class Http2SolrClientTest extends SolrJettyTestBase {}+ @Test+ public void test0IdleTimeout() throws Exception {+ SolrQuery q = new SolrQuery("*:*");+ try(Http2SolrClient client = getHttp2SolrClient(jetty.getBaseUrl().toString() + "/debug/foo", DEFAULT_CONNECTION_TIMEOUT, 0)) {+ try {+ client.query(q, SolrRequest.METHOD.GET);+ } catch (ParseException ignored) {}+ }++ }+/*** test that SolrExceptions thrown by HttpSolrClient can* correctly encapsulate http status codes even when not on the list of