Skip to content

Apache Lucene open-source search software

better error msg than NPE when collection cannot be found

Mark Robert Millerf733000e0f14
diff --git a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
index bf4f73a925b..be3831a7640 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/HttpShardHandler.java
@@ -26,6 +26,7 @@ import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.cloud.CloudDescriptor;
import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.SolrException;
+import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.CloudState;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkCoreNodeProps;
@@ -300,6 +301,11 @@ public class HttpShardHandler extends ShardHandler {
// If no collections were specified, default to the collection for
// this core.
slices = cloudState.getSlices(cloudDescriptor.getCollectionName());
+ if (slices == null) {
+ throw new SolrException(ErrorCode.BAD_REQUEST,
+ "Could not find collection:"
+ + cloudDescriptor.getCollectionName());
+ }
}
// Store the logical slices in the ResponseBuilder and create a new