SOLR-14351: Oops; add back null check for ZkController

This commit is contained in:
David Smiley 2020-05-03 10:23:16 -04:00
parent 96c47bc850
commit e7c7a62a84
No known key found for this signature in database
GPG Key ID: 6FDFF3BF6796FD4A
1 changed files with 13 additions and 1 deletions

View File

@ -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<CoreDescriptor> 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() {