From commits-return-119046-archive-asf-public=cust-asf.ponee.io@lucene.apache.org Fri Oct 16 09:56:31 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-he-de.apache.org (mxout1-he-de.apache.org [95.216.194.37]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 2D84218037A for ; Fri, 16 Oct 2020 11:56:31 +0200 (CEST) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-he-de.apache.org (ASF Mail Server at mxout1-he-de.apache.org) with SMTP id 7B13B6552F for ; Fri, 16 Oct 2020 09:56:29 +0000 (UTC) Received: (qmail 81875 invoked by uid 500); 16 Oct 2020 09:56:27 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 81730 invoked by uid 99); 16 Oct 2020 09:56:27 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Oct 2020 09:56:27 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 41BF081796; Fri, 16 Oct 2020 09:56:27 +0000 (UTC) Date: Fri, 16 Oct 2020 09:56:26 +0000 To: "commits@lucene.apache.org" Subject: [lucene-solr] 04/04: Fix NPE in CB Config Resolution MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: atri@apache.org In-Reply-To: <160284218164.18126.4433479502835356303@gitbox.apache.org> References: <160284218164.18126.4433479502835356303@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: lucene-solr X-Git-Refname: refs/heads/branch_8x X-Git-Reftype: branch X-Git-Rev: 327d54548dd30554b18f5afd0530cb04878fdf57 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20201016095627.41BF081796@gitbox.apache.org> 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 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);