Skip to content

Apache Lucene open-source search software

SOLR-5555: CloudSolrServer and LBHttpSolrServer shouldn't throw MUE from constructors

Alan Woodwardd22cffebb7a6
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6687631b590..e001f738c82 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -73,7 +73,9 @@ Apache ZooKeeper 3.4.5
Upgrading from Solr 4.6.0
----------------------
-
+
+* CloudSolrServer and LBHttpSolrServer no longer declare MalfurmedURLException
+ as thrown from their constructors.
Detailed Change List
----------------------
@@ -248,6 +250,9 @@ Other Changes
* SOLR-5548: Give DistributedSearchTestCase / JettySolrRunner the ability to
specify extra filters. (Greg Chanan via Mark Miller)
+* SOLR-5555: LBHttpSolrServer and CloudSolrServer constructors don't need to
+ declare MalformedURLExceptions (Sushil Bajracharya, Alan Woodward)
+
================== 4.6.0 ==================
Versions of Major Components
diff --git a/solr/contrib/morphlines-core/src/java/org/apache/solr/morphlines/solr/SolrLocator.java b/solr/contrib/morphlines-core/src/java/org/apache/solr/morphlines/solr/SolrLocator.java
index 2381a08b082..3254acd9326 100644
--- a/solr/contrib/morphlines-core/src/java/org/apache/solr/morphlines/solr/SolrLocator.java
+++ b/solr/contrib/morphlines-core/src/java/org/apache/solr/morphlines/solr/SolrLocator.java
@@ -16,12 +16,15 @@
*/
package org.apache.solr.morphlines.solr;
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
+import com.cloudera.cdk.morphline.api.MorphlineCompilationException;
+import com.cloudera.cdk.morphline.api.MorphlineContext;
+import com.cloudera.cdk.morphline.api.MorphlineRuntimeException;
+import com.cloudera.cdk.morphline.base.Configs;
+import com.google.common.base.Preconditions;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import com.typesafe.config.ConfigRenderOptions;
+import com.typesafe.config.ConfigUtil;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.common.cloud.SolrZkClient;
@@ -35,15 +38,9 @@ import org.slf4j.LoggerFactory;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
-import com.cloudera.cdk.morphline.api.MorphlineCompilationException;
-import com.cloudera.cdk.morphline.api.MorphlineContext;
-import com.cloudera.cdk.morphline.api.MorphlineRuntimeException;
-import com.cloudera.cdk.morphline.base.Configs;
-import com.google.common.base.Preconditions;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import com.typesafe.config.ConfigRenderOptions;
-import com.typesafe.config.ConfigUtil;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
/**
* Set of configuration parameters that identify the location and schema of a Solr server or
@@ -94,14 +91,10 @@ public class SolrLocator {
if (collectionName == null || collectionName.length() == 0) {
throw new MorphlineCompilationException("Parameter 'zkHost' requires that you also pass parameter 'collection'", config);
}
- try {
- CloudSolrServer cloudSolrServer = new CloudSolrServer(zkHost);
- cloudSolrServer.setDefaultCollection(collectionName);
- cloudSolrServer.connect();
- return new SolrServerDocumentLoader(cloudSolrServer, batchSize);
- } catch (MalformedURLException e) {
- throw new MorphlineRuntimeException(e);
- }
+ CloudSolrServer cloudSolrServer = new CloudSolrServer(zkHost);
+ cloudSolrServer.setDefaultCollection(collectionName);
+ cloudSolrServer.connect();
+ return new SolrServerDocumentLoader(cloudSolrServer, batchSize);
} else {
if (solrUrl == null || solrUrl.length() == 0) {
throw new MorphlineCompilationException("Missing parameter 'solrUrl'", config);
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
index d55e01f0701..a2432cd994f 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
@@ -16,19 +16,6 @@ package org.apache.solr.handler.component;
* limitations under the License.
*/
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
import org.apache.http.client.HttpClient;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
@@ -44,6 +31,18 @@ import org.apache.solr.util.DefaultSolrThreadFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
public class HttpShardHandlerFactory extends ShardHandlerFactory implements org.apache.solr.util.plugin.PluginInfoInitialized {
protected static Logger log = LoggerFactory.getLogger(HttpShardHandlerFactory.class);
@@ -158,12 +157,7 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory implements org.
}
protected LBHttpSolrServer createLoadbalancer(HttpClient httpClient){
- try {
- return new LBHttpSolrServer(httpClient);
- } catch (MalformedURLException e) {
- // should be impossible since we're not passing any URLs here
- throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
- }
+ return new LBHttpSolrServer(httpClient);
}
protected <T> T getParameter(NamedList initArgs, String configKey, T defaultValue) {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
index 1130e15cd0b..e2f9c813840 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrServer.java
@@ -119,7 +119,7 @@ public class CloudSolrServer extends SolrServer {
* @param zkHost The client endpoint of the zookeeper quorum containing the cloud state,
* in the form HOST:PORT.
*/
- public CloudSolrServer(String zkHost) throws MalformedURLException {
+ public CloudSolrServer(String zkHost) {
this.zkHost = zkHost;
this.myClient = HttpClientUtil.createClient(null);
this.lbServer = new LBHttpSolrServer(myClient);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
index 830b79e5dcb..e0ea9306a87 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
@@ -192,14 +192,12 @@ public class LBHttpSolrServer extends SolrServer {
}
/** The provided httpClient should use a multi-threaded connection manager */
- public LBHttpSolrServer(HttpClient httpClient, String... solrServerUrl)
- throws MalformedURLException {
+ public LBHttpSolrServer(HttpClient httpClient, String... solrServerUrl) {
this(httpClient, new BinaryResponseParser(), solrServerUrl);
}
/** The provided httpClient should use a multi-threaded connection manager */
- public LBHttpSolrServer(HttpClient httpClient, ResponseParser parser, String... solrServerUrl)
- throws MalformedURLException {
+ public LBHttpSolrServer(HttpClient httpClient, ResponseParser parser, String... solrServerUrl) {
clientIsInternal = (httpClient == null);
this.parser = parser;
if (httpClient == null) {
@@ -234,7 +232,7 @@ public class LBHttpSolrServer extends SolrServer {
return server;
}
- protected HttpSolrServer makeServer(String server) throws MalformedURLException {
+ protected HttpSolrServer makeServer(String server) {
HttpSolrServer s = new HttpSolrServer(server, httpClient, parser);
if (requestWriter != null) {
s.setRequestWriter(requestWriter);