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 68b0a3744bf..8053db034b8 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 @@ -302,6 +302,10 @@ public class CloudSolrServer extends SolrServer { //The value is a list of URLs for each replica in the slice. //The first value in the list is the leader for the slice. Map> urlMap = buildUrlMap(col); + if (urlMap == null) { + // we could not find a leader yet - use unoptimized general path + return null; + } NamedList exceptions = new NamedList(); NamedList shardResponses = new NamedList(); @@ -314,7 +318,7 @@ public class CloudSolrServer extends SolrServer { long start = System.nanoTime(); if (parallelUpdates) { - final Map>> responseFutures = new HashMap>>(); + final Map>> responseFutures = new HashMap>>(routes.size()); for (final Map.Entry entry : routes.entrySet()) { final String url = entry.getKey(); final LBHttpSolrServer.Req lbRequest = entry.getValue(); @@ -402,6 +406,10 @@ public class CloudSolrServer extends SolrServer { String name = slice.getName(); List urls = new ArrayList(); Replica leader = slice.getLeader(); + if (leader == null) { + // take unoptimized general path - we cannot find a leader yet + return null; + } ZkCoreNodeProps zkProps = new ZkCoreNodeProps(leader); String url = zkProps.getBaseUrl() + "/" + col.getName(); urls.add(url);