Apache Solr open-source search software
SOLR-10196: ElectionContext#runLeaderProcess can hit NPE on core close.
markrmiller04ba9968c068
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 0f1cac5a3b7..07f1c4e4e8e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -186,6 +186,8 @@ Bug Fixes* SOLR-10055: Linux installer now renames existing bin/solr.in.* as bin/solr.in.*.orig to make the installed config in/etc/defaults be the one found by default when launching solr manually. (janhoy)+* SOLR-10196: ElectionContext#runLeaderProcess can hit NPE on core close. (Mark Miller)+Optimizations----------------------diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.javaindex 6c073b916ab..ff6fb3031c1 100644--- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java+++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java@@ -423,8 +423,12 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {super.runLeaderProcess(weAreReplacement, 0);try (SolrCore core = cc.getCore(coreName)) {- core.getCoreDescriptor().getCloudDescriptor().setLeader(true);- publishActiveIfRegisteredAndNotActive(core);+ if (core != null) {+ core.getCoreDescriptor().getCloudDescriptor().setLeader(true);+ publishActiveIfRegisteredAndNotActive(core);+ } else {+ return;+ }}log.info("I am the new leader: " + ZkCoreNodeProps.getCoreUrl(leaderProps) + " " + shardId);diff --git a/solr/core/src/test/org/apache/solr/cloud/CleanupOldIndexTest.java b/solr/core/src/test/org/apache/solr/cloud/CleanupOldIndexTest.javaindex cc03a259595..547de8df805 100644--- a/solr/core/src/test/org/apache/solr/cloud/CleanupOldIndexTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/CleanupOldIndexTest.java@@ -47,7 +47,7 @@ public class CleanupOldIndexTest extends SolrCloudTestCase {}@AfterClass- public static void teardownTestCases() throws Exception {+ public static void afterClass() throws Exception {if (suiteFailureMarker.wasSuccessful()) {zkClient().printLayoutToStdOut();