Apache Solr open-source search software
SOLR-5678: SolrZkClient should throw a SolrException when connect times out rather than a RuntimeException.
Mark Robert Miller8b4ea8885e22
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex ebae0d33d1d..7bee2186c9a 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -273,6 +273,9 @@ Bug Fixes* SOLR-5593: Replicas should accept the last updates from a leader that has justlost it's connection to ZooKeeper. (Christine Poerschke via Mark Miller)+* SOLR-5678: SolrZkClient should throw a SolrException when connect times out+ rather than a RuntimeException. (Karl Wright, Anshum Gupta+Optimizations----------------------diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java b/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.javaindex 71f66a84da9..8cce7d91026 100644--- a/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java@@ -29,6 +29,7 @@ import org.apache.commons.io.IOUtils;import org.apache.commons.io.filefilter.RegexFileFilter;import org.apache.commons.io.filefilter.TrueFileFilter;import org.apache.solr.SolrTestCaseJ4;+import org.apache.solr.common.SolrException;import org.apache.solr.common.cloud.SolrZkClient;import org.apache.solr.common.cloud.ZkNodeProps;import org.apache.solr.common.cloud.ZkStateReader;@@ -305,6 +306,12 @@ public class ZkCLITest extends SolrTestCaseJ4 {}}+ @Test(expected = SolrException.class)+ public void testInvalidZKAddress() throws SolrException{+ SolrZkClient zkClient = new SolrZkClient("----------:33332", 100);+ zkClient.close();+ }+@Overridepublic void tearDown() throws Exception {if (VERBOSE) {diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.javaindex 0ac1d3937e2..091529950c7 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ConnectionManager.java@@ -229,7 +229,7 @@ public class ConnectionManager implements Watcher {wait(500);} catch (InterruptedException e) {Thread.currentThread().interrupt();- throw new RuntimeException(e);+ break;}left = expire - System.currentTimeMillis();}diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.javaindex fcd9be1c4a5..54cc3c8aaed 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/SolrZkClient.java@@ -24,6 +24,7 @@ import java.io.StringWriter;import java.io.UnsupportedEncodingException;import java.net.URLDecoder;import java.util.List;+import java.util.concurrent.TimeoutException;import java.util.concurrent.atomic.AtomicLong;import javax.xml.transform.OutputKeys;@@ -132,7 +133,7 @@ public class SolrZkClient {Thread.currentThread().interrupt();}}- throw new RuntimeException(e);+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);}try {@@ -144,7 +145,7 @@ public class SolrZkClient {} catch (InterruptedException e1) {Thread.currentThread().interrupt();}- throw new RuntimeException(e);+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);}numOpens.incrementAndGet();}