From 93d7c7ae6ba6edc8ca02caf7d4a8e29da016d032 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Wed, 15 May 2013 17:01:49 +0000 Subject: [PATCH] SOLR-4734: Leader election fails with an NPE if there is no UpdateLog git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1482955 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../src/java/org/apache/solr/cloud/ElectionContext.java | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 8854d0ca88e..fe087f6d3e9 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -110,6 +110,9 @@ Bug Fixes * SOLR-4796: zkcli.sh should honor JAVA_HOME (Roman Shaposhnik via Mark Miller) +* SOLR-4734: Leader election fails with an NPE if there is no UpdateLog. + (Mark Miller, Alexander Eibner) + Other Changes ---------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java index 8194ffdbb3e..d34aa34e493 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java +++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java @@ -172,8 +172,6 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase { } log.info("I may be the new leader - try and sync"); - - UpdateLog ulog = core.getUpdateHandler().getUpdateLog(); // we are going to attempt to be the leader @@ -187,7 +185,9 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase { success = false; } - if (!success && ulog.getRecentUpdates().getVersions(1).isEmpty()) { + UpdateLog ulog = core.getUpdateHandler().getUpdateLog(); + + if (!success && (ulog == null || ulog.getRecentUpdates().getVersions(1).isEmpty())) { // we failed sync, but we have no versions - we can't sync in that case // - we were active // before, so become leader anyway