mirror of https://github.com/apache/lucene.git
SOLR-11425: SolrClientBuilder does not allow infinite timeout (value 0).
This commit is contained in:
parent
a9fb4ddf80
commit
fc429399ec
|
@ -156,6 +156,7 @@ Bug Fixes
|
||||||
* SOLR-11278: Fix a race condition in the CDCR bootstrap process which could lead to bootstraps cancelling itself
|
* SOLR-11278: Fix a race condition in the CDCR bootstrap process which could lead to bootstraps cancelling itself
|
||||||
(Amrit Sarkar, shalin, Varun Thacker)
|
(Amrit Sarkar, shalin, Varun Thacker)
|
||||||
|
|
||||||
|
* SOLR-11425: SolrClientBuilder does not allow infinite timeout (value 0). (Peter Szantai-Kis via Mark Miller)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
@ -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.
|
* 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) {
|
public B withConnectionTimeout(int connectionTimeoutMillis) {
|
||||||
if (connectionTimeoutMillis <= 0) {
|
if (connectionTimeoutMillis < 0) {
|
||||||
throw new IllegalArgumentException("connectionTimeoutMillis must be a positive integer.");
|
throw new IllegalArgumentException("connectionTimeoutMillis must be a non-negative integer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connectionTimeoutMillis = connectionTimeoutMillis;
|
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.
|
* 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) {
|
public B withSocketTimeout(int socketTimeoutMillis) {
|
||||||
if (socketTimeoutMillis <= 0) {
|
if (socketTimeoutMillis < 0) {
|
||||||
throw new IllegalArgumentException("socketTimeoutMillis must be a positive integer.");
|
throw new IllegalArgumentException("socketTimeoutMillis must be a non-negative integer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socketTimeoutMillis = socketTimeoutMillis;
|
this.socketTimeoutMillis = socketTimeoutMillis;
|
||||||
|
|
|
@ -97,4 +97,15 @@ public class CloudSolrClientBuilderTest extends LuceneTestCase {
|
||||||
assertFalse(createdClient.isDirectUpdatesToLeadersOnly());
|
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()) {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue