diff --git a/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerManager.java b/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerManager.java index 975ca4b124e..2f6f93dd736 100644 --- a/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerManager.java +++ b/solr/core/src/java/org/apache/solr/util/circuitbreaker/CircuitBreakerManager.java @@ -137,7 +137,8 @@ public class CircuitBreakerManager implements PluginInfoInitialized { */ @SuppressWarnings({"rawtypes"}) public static CircuitBreakerManager build(PluginInfo pluginInfo) { - CircuitBreakerManager circuitBreakerManager = new CircuitBreakerManager(Boolean.parseBoolean(pluginInfo.attributes.get("enabled"))); + boolean enabled = pluginInfo == null ? false : Boolean.parseBoolean(pluginInfo.attributes.getOrDefault("enabled", "false")); + CircuitBreakerManager circuitBreakerManager = new CircuitBreakerManager(enabled); circuitBreakerManager.init(pluginInfo); @@ -147,19 +148,24 @@ public class CircuitBreakerManager implements PluginInfoInitialized { @VisibleForTesting @SuppressWarnings({"rawtypes"}) public static CircuitBreaker.CircuitBreakerConfig buildCBConfig(PluginInfo pluginInfo) { - boolean enabled = Boolean.parseBoolean(pluginInfo.attributes.get("enabled")); + boolean enabled = false; boolean cpuCBEnabled = false; boolean memCBEnabled = false; int memCBThreshold = 100; int cpuCBThreshold = 100; - NamedList args = pluginInfo.initArgs; - if (args != null) { - cpuCBEnabled = args.getBooleanArg("cpuEnabled"); - memCBEnabled = args.getBooleanArg("memEnabled"); - memCBThreshold = Integer.parseInt((String) args.get("memThreshold")); - cpuCBThreshold = Integer.parseInt((String) args.get("cpuThreshold")); + if (pluginInfo != null) { + NamedList args = pluginInfo.initArgs; + + enabled = Boolean.parseBoolean(pluginInfo.attributes.getOrDefault("enabled", "false")); + + if (args != null) { + cpuCBEnabled = Boolean.parseBoolean(args._getStr("cpuEnabled", "false")); + memCBEnabled = Boolean.parseBoolean(args._getStr("memEnabled", "false")); + memCBThreshold = Integer.parseInt(args._getStr("memThreshold", "100")); + cpuCBThreshold = Integer.parseInt(args._getStr("cpuThreshold", "100")); + } } return new CircuitBreaker.CircuitBreakerConfig(enabled, memCBEnabled, memCBThreshold, cpuCBEnabled, cpuCBThreshold);