lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [lucene-solr] 04/04: Fix NPE in CB Config Resolution
Date Fri, 16 Oct 2020 09:56:26 GMT
This is an automated email from the ASF dual-hosted git repository.

atri pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 327d54548dd30554b18f5afd0530cb04878fdf57
Author: Atri Sharma <atri.jiit@gmail.com>
AuthorDate: Thu Aug 27 20:52:12 2020 +0530

    Fix NPE in CB Config Resolution
---
 .../util/circuitbreaker/CircuitBreakerManager.java | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

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 975ca4b..2f6f93d 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);


Mime
View raw message