From e7c7a62a84927cf6c49d75229f9ebfbe2feb9df9 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Sun, 3 May 2020 10:23:16 -0400 Subject: [PATCH] SOLR-14351: Oops; add back null check for ZkController --- .../src/java/org/apache/solr/core/ZkContainer.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/solr/core/src/java/org/apache/solr/core/ZkContainer.java b/solr/core/src/java/org/apache/solr/core/ZkContainer.java index 3df1c53cc75..2ca62f8b37d 100644 --- a/solr/core/src/java/org/apache/solr/core/ZkContainer.java +++ b/solr/core/src/java/org/apache/solr/core/ZkContainer.java @@ -47,7 +47,16 @@ import org.apache.zookeeper.KeeperException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Used by {@link CoreContainer} to hold ZooKeeper / SolrCloud info, especially {@link ZkController}. + * Mainly it does some ZK initialization, and ensures a loading core registers in ZK. + * Even when in standalone mode, perhaps surprisingly, an instance of this class exists. + * If {@link #getZkController()} returns null then we're in standalone mode. + */ public class ZkContainer { + // NOTE DWS: It's debatable if this in-between class is needed instead of folding it all into ZkController. + // ZKC is huge though. + private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); protected ZkController zkController; @@ -180,6 +189,10 @@ public class ZkContainer { public static volatile Predicate testing_beforeRegisterInZk; public void registerInZk(final SolrCore core, boolean background, boolean skipRecovery) { + if (zkController == null) { + return; + } + CoreDescriptor cd = core.getCoreDescriptor(); // save this here - the core may not have it later Runnable r = () -> { MDCLoggingContext.setCore(core); @@ -223,7 +236,6 @@ public class ZkContainer { } else { r.run(); } - } public ZkController getZkController() {