Apache Solr open-source search software
SOLR-16145: NPE fix in rejoinOverseerElection (#793)
David Smileyef2b725931dd
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 859b669fb98..a4e38d5c021 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -65,6 +65,8 @@ Bug Fixes* SOLR-13044: Fix NPE during core close racing with index replication check. (David Smiley, hossman)+* SOLR-16145: Fix very rare NPE in SolrCloud rejoinOverseerElection. (David Smiley)+* SOLR-16168: Spellcheck NPE if invalid dictionary name is provided (Kevin Risden)Other Changesdiff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.javaindex 0778f7e9b66..1a1d050941b 100644--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java@@ -2346,15 +2346,16 @@ public class ZkController implements Closeable {public void rejoinOverseerElection(String electionNode, boolean joinAtHead) {try {+ final ElectionContext context = overseerElector.getContext();if (electionNode != null) {// Check whether we came to this node by mistake- if (overseerElector.getContext() != null- && overseerElector.getContext().leaderSeqPath == null- && !overseerElector.getContext().leaderSeqPath.endsWith(electionNode)) {+ if (context != null+ && context.leaderSeqPath != null+ && !context.leaderSeqPath.endsWith(electionNode)) {log.warn("Asked to rejoin with wrong election node : {}, current node is {}",electionNode,- overseerElector.getContext().leaderSeqPath);+ context.leaderSeqPath);// however delete it . This is possible when the last attempt at deleting the election// node failed.if (electionNode.startsWith(getNodeName())) {@@ -2377,7 +2378,7 @@ public class ZkController implements Closeable {return;}} else {- overseerElector.retryElection(overseerElector.getContext(), joinAtHead);+ overseerElector.retryElection(context, joinAtHead);}} catch (Exception e) {throw new SolrException(ErrorCode.SERVER_ERROR, "Unable to rejoin election", e);