lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject lucene-solr:master: SOLR-11425: SolrClientBuilder does not allow infinite timeout (value 0).
Date Tue, 03 Oct 2017 15:18:58 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master a9fb4ddf8 -> fc429399e


SOLR-11425: SolrClientBuilder does not allow infinite timeout (value 0).


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/fc429399
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/fc429399
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/fc429399

Branch: refs/heads/master
Commit: fc429399ecd917bd2fd1902f8a47e32d9093a786
Parents: a9fb4dd
Author: markrmiller <markrmiller@apache.org>
Authored: Mon Oct 2 22:55:37 2017 -0500
Committer: markrmiller <markrmiller@apache.org>
Committed: Tue Oct 3 09:08:26 2017 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                      |  1 +
 .../solr/client/solrj/impl/SolrClientBuilder.java     | 14 ++++++++++----
 .../client/solrj/impl/CloudSolrClientBuilderTest.java | 11 +++++++++++
 3 files changed, 22 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fc429399/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 177cdf7..c14c9b6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -156,6 +156,7 @@ Bug Fixes
 * SOLR-11278: Fix a race condition in the CDCR bootstrap process which could lead to bootstraps
cancelling itself
   (Amrit Sarkar, shalin, Varun Thacker)
 
+* SOLR-11425: SolrClientBuilder does not allow infinite timeout (value 0). (Peter Szantai-Kis
via Mark Miller)
 
 Optimizations
 ----------------------

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fc429399/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientBuilder.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientBuilder.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientBuilder.java
index ec149bd..74e981d 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientBuilder.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/SolrClientBuilder.java
@@ -48,10 +48,13 @@ public abstract class SolrClientBuilder<B extends SolrClientBuilder<B>>
{
   
   /**
    * Tells {@link Builder} that created clients should obey the following timeout when connecting
to Solr servers.
+   * <p>
+   * For valid values see {@link org.apache.http.client.config.RequestConfig#getConnectTimeout()}
+   * </p>
    */
   public B withConnectionTimeout(int connectionTimeoutMillis) {
-    if (connectionTimeoutMillis <= 0) {
-      throw new IllegalArgumentException("connectionTimeoutMillis must be a positive integer.");
+    if (connectionTimeoutMillis < 0) {
+      throw new IllegalArgumentException("connectionTimeoutMillis must be a non-negative
integer.");
     }
     
     this.connectionTimeoutMillis = connectionTimeoutMillis;
@@ -60,10 +63,13 @@ public abstract class SolrClientBuilder<B extends SolrClientBuilder<B>>
{
   
   /**
    * Tells {@link Builder} that created clients should set the following read timeout on
all sockets.
+   * <p>
+   * For valid values see {@link org.apache.http.client.config.RequestConfig#getSocketTimeout()}
+   * </p>
    */
   public B withSocketTimeout(int socketTimeoutMillis) {
-    if (socketTimeoutMillis <= 0) {
-      throw new IllegalArgumentException("socketTimeoutMillis must be a positive integer.");
+    if (socketTimeoutMillis < 0) {
+      throw new IllegalArgumentException("socketTimeoutMillis must be a non-negative integer.");
     }
     
     this.socketTimeoutMillis = socketTimeoutMillis;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/fc429399/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
index 4c38554..97b79ef 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
@@ -97,4 +97,15 @@ public class CloudSolrClientBuilderTest extends LuceneTestCase {
       assertFalse(createdClient.isDirectUpdatesToLeadersOnly());
     }
   }
+  
+  @Test
+  public void test0Timeouts() throws IOException {
+    try(CloudSolrClient createdClient = new Builder()
+        .withZkHost(ANY_ZK_HOST)
+        .withZkChroot(ANY_CHROOT)
+        .withSocketTimeout(0)
+        .withConnectionTimeout(0)
+        .build()) {
+    }
+  }
 }


Mime
View raw message