You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2020/02/20 12:29:37 UTC
[lucene-solr] branch master updated: SOLR-12550:
ConcurrentUpdateSolrClient doesn't respect timeouts for commits and
optimize (#417)
This is an automated email from the ASF dual-hosted git repository.
shalin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 051133c SOLR-12550: ConcurrentUpdateSolrClient doesn't respect timeouts for commits and optimize (#417)
051133c is described below
commit 051133c13f982e72aabf914350c65e3dd8aa961d
Author: Marc A. Morissette <ma...@gmail.com>
AuthorDate: Thu Feb 20 07:29:20 2020 -0500
SOLR-12550: ConcurrentUpdateSolrClient doesn't respect timeouts for commits and optimize (#417)
ConcurrentUpdateSolrClient now propagates its connection and read timeouts to the private HttpSolrClient used to commit and optimize.
---
.../solrj/impl/ConcurrentUpdateSolrClient.java | 2 ++
.../ConcurrentUpdateSolrClientBuilderTest.java | 29 ++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
index edc8270..c774e03 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
@@ -125,6 +125,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
this.internalHttpClient = (builder.httpClient == null);
this.client = new HttpSolrClient.Builder(builder.baseSolrUrl)
.withHttpClient(builder.httpClient)
+ .withConnectionTimeout(builder.connectionTimeoutMillis)
+ .withSocketTimeout(builder.socketTimeoutMillis)
.build();
this.client.setFollowRedirects(false);
this.queue = new LinkedBlockingQueue<>(builder.queueSize);
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java
index af120fc..282b88d 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java
@@ -17,7 +17,13 @@
package org.apache.solr.client.solrj.impl;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.SocketTimeoutException;
+
import org.apache.solr.SolrTestCase;
+import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient.Builder;
import org.junit.Test;
@@ -39,4 +45,27 @@ public class ConcurrentUpdateSolrClientBuilderTest extends SolrTestCase {
// is the baseSolrUrl
}
}
+
+ /**
+ * Test that connection timeout information is passed to the HttpSolrClient that handles non add operations.
+ */
+ @Test(timeout = 10000)
+ public void testSocketTimeoutOnCommit() throws IOException, SolrServerException {
+ InetAddress localHost = InetAddress.getLocalHost();
+ try (ServerSocket server = new ServerSocket(0, 1, localHost);
+ ConcurrentUpdateSolrClient client = new ConcurrentUpdateSolrClient.Builder(
+ "http://" + localHost.getHostAddress() + ":" + server.getLocalPort() + "/noOneThere")
+ .withSocketTimeout(1)
+ .build()){
+ // Expecting an exception
+ client.commit();
+ fail();
+ }
+ catch (SolrServerException e) {
+ if (!(e.getCause() instanceof SocketTimeoutException)) {
+ throw e;
+ }
+ // else test passses
+ }
+ }
}