From 6fa596884bcf47774ecb5d8b6a95b30b9c3e7c7b Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Wed, 22 Apr 2015 12:18:41 -0400 Subject: [PATCH] NIFI-535: Fixed NPE in SnippetUtils --- .../org/apache/nifi/web/util/SnippetUtils.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java index 40e5730527..76789c606d 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/util/SnippetUtils.java @@ -194,13 +194,21 @@ public final class SnippetUtils { } private void addControllerServicesToSnippet(final FlowSnippetDTO snippetDto) { - for ( final ProcessorDTO processorDto : snippetDto.getProcessors() ) { - addControllerServicesToSnippet(snippetDto, processorDto); + final Set processors = snippetDto.getProcessors(); + if ( processors != null ) { + for ( final ProcessorDTO processorDto : processors ) { + addControllerServicesToSnippet(snippetDto, processorDto); + } } - for ( final ProcessGroupDTO processGroupDto : snippetDto.getProcessGroups() ) { - final FlowSnippetDTO childGroupDto = processGroupDto.getContents(); - addControllerServicesToSnippet(childGroupDto); + final Set childGroups = snippetDto.getProcessGroups(); + if ( childGroups != null ) { + for ( final ProcessGroupDTO processGroupDto : childGroups ) { + final FlowSnippetDTO childGroupDto = processGroupDto.getContents(); + if ( childGroupDto != null ) { + addControllerServicesToSnippet(childGroupDto); + } + } } }