From 164e0c41867bb3a486f077dbd79e8c9d379120e8 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Mon, 5 Aug 2019 14:17:16 -0400 Subject: [PATCH] NIFI-6380: Fixed NPE that is thrown when clustered and using parameters from Controller Services This closes #3635 --- .../http/endpoints/ParameterContextMerger.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ParameterContextMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ParameterContextMerger.java index 7278b54289..805aff7720 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ParameterContextMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ParameterContextMerger.java @@ -142,7 +142,7 @@ public class ParameterContextMerger { final AffectedComponentDTO mergedComponent = merged.getComponent(); final AffectedComponentDTO additionalComponent = additional.getComponent(); - mergedComponent.setActiveThreadCount(mergedComponent.getActiveThreadCount() + additionalComponent.getActiveThreadCount()); + mergedComponent.setActiveThreadCount(add(mergedComponent.getActiveThreadCount(), additionalComponent.getActiveThreadCount())); if (mergedComponent.getValidationErrors() == null) { mergedComponent.setValidationErrors(new ArrayList<>()); @@ -152,4 +152,14 @@ public class ParameterContextMerger { mergedComponent.getValidationErrors().addAll(additionalComponent.getValidationErrors()); } } + + private static Integer add(final Integer a, final Integer b) { + if (a == null) { + return b; + } + if (b == null) { + return a; + } + return a + b; + } }