From 3bbf8aaa8a9f57c43d64e9c361184c379d90b9c9 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Tue, 5 Apr 2016 14:15:31 -0400 Subject: [PATCH] SOLR-8875: Fix null clusterState from ZkStateWriter. Revert my sanity check asserts in Overseer. --- solr/CHANGES.txt | 3 +++ solr/core/src/java/org/apache/solr/cloud/Overseer.java | 1 + .../java/org/apache/solr/cloud/overseer/ZkStateWriter.java | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5ab52b29542..9e6da65d9ce 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -101,6 +101,9 @@ Bug Fixes * SOLR-8902: Make sure ReturnFields only returns the requested fields from (fl=) evn when DocumentTransformers ask for getExtraRequestFields() (ryan) +* SOLR-8875: SolrCloud Overseer clusterState could unexpectedly be null resulting in NPE. + (Scott Blum via David Smiley) + Optimizations ---------------------- * SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation. diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java index 0e5bded5f3f..f25cab7b670 100644 --- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java +++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java @@ -151,6 +151,7 @@ public class Overseer implements Closeable { continue; // not a no, not a yes, try ask again } + //TODO consider removing 'refreshClusterState' and simply check if clusterState is null if (refreshClusterState) { try { reader.updateClusterState(); diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java index 9fb3ada40c6..ec67ed7dbc4 100644 --- a/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java +++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ZkStateWriter.java @@ -16,6 +16,7 @@ */ package org.apache.solr.cloud.overseer; +import java.lang.invoke.MethodHandles; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -35,8 +36,6 @@ import org.slf4j.LoggerFactory; import static java.util.Collections.singletonMap; -import java.lang.invoke.MethodHandles; - /** * ZkStateWriter is responsible for writing updates to the cluster state stored in ZooKeeper for * both stateFormat=1 collection (stored in shared /clusterstate.json in ZK) and stateFormat=2 collections @@ -84,6 +83,7 @@ public class ZkStateWriter { this.reader = zkStateReader; this.stats = stats; + this.clusterState = zkStateReader.getClusterState(); } /**