Apache Solr open-source search software
SOLR-8254: HttpSolrCore.getCoreByCollection() can throw NPE
Alan Woodward1057db3e1488
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex f25e600fd1f..100967cc01b 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -351,6 +351,9 @@ Bug Fixes* SOLR-8255: MiniSolrCloudCluster needs to use a thread-safe list to keep trackof its child nodes (Alan Woodward)+* SOLR-8254: HttpSolrCore.getCoreByCollection() can throw NPE (Alan Woodward,+ Mark Miller)+Optimizations----------------------diff --git a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.javaindex e5329e093dc..e094bffc848 100644--- a/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java+++ b/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java@@ -783,10 +783,8 @@ public class HttpSolrCall {for (Map.Entry<String, Slice> entry : entries) {// first see if we have the leaderReplica leaderProps = clusterState.getLeader(collection, entry.getKey());- if (liveNodes.contains(leaderProps.getNodeName()) && leaderProps.getState() == Replica.State.ACTIVE) {- if (leaderProps != null) {- core = checkProps(leaderProps);- }+ if (leaderProps != null && liveNodes.contains(leaderProps.getNodeName()) && leaderProps.getState() == Replica.State.ACTIVE) {+ core = checkProps(leaderProps);if (core != null) {return core;}