From 28cd5d1300f9d2c9fd957a9d92a9096b5cd0edfb Mon Sep 17 00:00:00 2001 From: Joe Gresock Date: Thu, 28 Oct 2021 12:06:56 -0400 Subject: [PATCH] NIFI-9345: Resolving NPE in ProcessorEntityMerger (#5491) NIFI-9345: Resolving NPE in ProcessorEntityMerger, Streamlining forEach calls --- .../cluster/manager/ControllerServiceEntityMerger.java | 2 +- .../nifi/cluster/manager/ProcessorEntityMerger.java | 8 +++++--- .../nifi/cluster/manager/ReportingTaskEntityMerger.java | 8 +++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ControllerServiceEntityMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ControllerServiceEntityMerger.java index 79913e4b10..41ee4d482b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ControllerServiceEntityMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ControllerServiceEntityMerger.java @@ -90,7 +90,7 @@ public class ControllerServiceEntityMerger implements ComponentEntityMerger descriptors = nodeControllerService.getDescriptors(); if (descriptors != null) { - descriptors.values().stream().forEach(propertyDescriptor -> { + descriptors.values().forEach(propertyDescriptor -> { propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); }); } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ProcessorEntityMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ProcessorEntityMerger.java index 55dce23322..e2e8d55ad8 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ProcessorEntityMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ProcessorEntityMerger.java @@ -86,9 +86,11 @@ public class ProcessorEntityMerger implements ComponentEntityMerger { - propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); - }); + if (nodeProcessor.getConfig().getDescriptors() != null) { + nodeProcessor.getConfig().getDescriptors().values().forEach(propertyDescriptor -> { + propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); + }); + } // if any node does not support multiple versions (null or false), make it unavailable if (clientDto.getMultipleVersionsAvailable() == null || !Boolean.TRUE.equals(nodeProcessor.getMultipleVersionsAvailable())) { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ReportingTaskEntityMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ReportingTaskEntityMerger.java index b439eaae40..2784776e29 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ReportingTaskEntityMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/ReportingTaskEntityMerger.java @@ -73,9 +73,11 @@ public class ReportingTaskEntityMerger implements ComponentEntityMerger { - propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); - }); + if (nodeReportingTask.getDescriptors() != null) { + nodeReportingTask.getDescriptors().values().forEach(propertyDescriptor -> { + propertyDescriptorMap.computeIfAbsent(propertyDescriptor.getName(), nodeIdToPropertyDescriptor -> new HashMap<>()).put(nodeId, propertyDescriptor); + }); + } } }