NIFI-9345: Resolving NPE in ProcessorEntityMerger (#5491)

NIFI-9345: Resolving NPE in ProcessorEntityMerger, Streamlining forEach calls
This commit is contained in:
Joe Gresock 2021-10-28 12:06:56 -04:00 committed by GitHub
parent 74151eab1f
commit 28cd5d1300
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -90,7 +90,7 @@ public class ControllerServiceEntityMerger implements ComponentEntityMerger<Cont
// aggregate the property descriptors
final Map<String, PropertyDescriptorDTO> 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);
});
}

View File

@ -86,9 +86,11 @@ public class ProcessorEntityMerger implements ComponentEntityMerger<ProcessorEnt
ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeProcessor.getValidationErrors());
// aggregate the property descriptors
nodeProcessor.getConfig().getDescriptors().values().stream().forEach(propertyDescriptor -> {
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())) {

View File

@ -73,9 +73,11 @@ public class ReportingTaskEntityMerger implements ComponentEntityMerger<Reportin
ErrorMerger.mergeErrors(validationErrorMap, nodeId, nodeReportingTask.getValidationErrors());
// aggregate the property descriptors
nodeReportingTask.getDescriptors().values().stream().forEach(propertyDescriptor -> {
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);
});
}
}
}