mirror of https://github.com/apache/lucene.git
Fix NPE in CB Config Resolution
This commit is contained in:
parent
6a7da3cd50
commit
b381595f55
|
@ -137,7 +137,8 @@ public class CircuitBreakerManager implements PluginInfoInitialized {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes"})
|
@SuppressWarnings({"rawtypes"})
|
||||||
public static CircuitBreakerManager build(PluginInfo pluginInfo) {
|
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);
|
circuitBreakerManager.init(pluginInfo);
|
||||||
|
|
||||||
|
@ -147,19 +148,24 @@ public class CircuitBreakerManager implements PluginInfoInitialized {
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@SuppressWarnings({"rawtypes"})
|
@SuppressWarnings({"rawtypes"})
|
||||||
public static CircuitBreaker.CircuitBreakerConfig buildCBConfig(PluginInfo pluginInfo) {
|
public static CircuitBreaker.CircuitBreakerConfig buildCBConfig(PluginInfo pluginInfo) {
|
||||||
boolean enabled = Boolean.parseBoolean(pluginInfo.attributes.get("enabled"));
|
boolean enabled = false;
|
||||||
boolean cpuCBEnabled = false;
|
boolean cpuCBEnabled = false;
|
||||||
boolean memCBEnabled = false;
|
boolean memCBEnabled = false;
|
||||||
int memCBThreshold = 100;
|
int memCBThreshold = 100;
|
||||||
int cpuCBThreshold = 100;
|
int cpuCBThreshold = 100;
|
||||||
|
|
||||||
NamedList args = pluginInfo.initArgs;
|
|
||||||
|
|
||||||
if (args != null) {
|
if (pluginInfo != null) {
|
||||||
cpuCBEnabled = args.getBooleanArg("cpuEnabled");
|
NamedList args = pluginInfo.initArgs;
|
||||||
memCBEnabled = args.getBooleanArg("memEnabled");
|
|
||||||
memCBThreshold = Integer.parseInt((String) args.get("memThreshold"));
|
enabled = Boolean.parseBoolean(pluginInfo.attributes.getOrDefault("enabled", "false"));
|
||||||
cpuCBThreshold = Integer.parseInt((String) args.get("cpuThreshold"));
|
|
||||||
|
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);
|
return new CircuitBreaker.CircuitBreakerConfig(enabled, memCBEnabled, memCBThreshold, cpuCBEnabled, cpuCBThreshold);
|
||||||
|
|
Loading…
Reference in New Issue