Repository: nifi Updated Branches: refs/heads/master 14eaeeb1e -> 5764e8929
NIFI-975 Fixing NullPointerException when one of the delimiters is not provided when using the Text strategy Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/5764e892 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/5764e892 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/5764e892 Branch: refs/heads/master Commit: 5764e892933f3fac958b39fe2c9a3cfde8afd59e Parents: 14eaeeb Author: Bryan Bende <[email protected]> Authored: Tue Sep 22 13:19:15 2015 -0400 Committer: Bryan Bende <[email protected]> Committed: Tue Sep 22 13:19:15 2015 -0400 ---------------------------------------------------------------------- .../nifi/processors/standard/MergeContent.java | 5 ++++- .../processors/standard/TestMergeContent.java | 21 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/5764e892/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java index c8f9bbe..e9258df 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/MergeContent.java @@ -641,7 +641,10 @@ public class MergeContent extends BinFiles { if (wrapper != null) { final FlowFile flowFile = wrapper.getFlowFile(); if (flowFile != null) { - property = context.getProperty(descriptor).evaluateAttributeExpressions(flowFile).getValue().getBytes(); + final String value = context.getProperty(descriptor).evaluateAttributeExpressions(flowFile).getValue(); + if (value != null) { + property = value.getBytes(); + } } } } http://git-wip-us.apache.org/repos/asf/nifi/blob/5764e892/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestMergeContent.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestMergeContent.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestMergeContent.java index c53c488..cd06ba0 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestMergeContent.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestMergeContent.java @@ -257,6 +257,27 @@ public class TestMergeContent { } @Test + public void testSimpleBinaryConcatWithTextDelimitersHeaderOnly() throws IOException, InterruptedException { + final TestRunner runner = TestRunners.newTestRunner(new MergeContent()); + runner.setProperty(MergeContent.MAX_BIN_AGE, "1 sec"); + runner.setProperty(MergeContent.MERGE_FORMAT, MergeContent.MERGE_FORMAT_CONCAT); + runner.setProperty(MergeContent.DELIMITER_STRATEGY, MergeContent.DELIMITER_STRATEGY_TEXT); + runner.setProperty(MergeContent.HEADER, "@"); + + createFlowFiles(runner); + runner.run(); + + runner.assertQueueEmpty(); + runner.assertTransferCount(MergeContent.REL_MERGED, 1); + runner.assertTransferCount(MergeContent.REL_FAILURE, 0); + runner.assertTransferCount(MergeContent.REL_ORIGINAL, 3); + + final MockFlowFile bundle = runner.getFlowFilesForRelationship(MergeContent.REL_MERGED).get(0); + bundle.assertContentEquals("@Hello, World!".getBytes("UTF-8")); + bundle.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), "application/plain-text"); + } + + @Test public void testSimpleBinaryConcatWithFileDelimiters() throws IOException, InterruptedException { final TestRunner runner = TestRunners.newTestRunner(new MergeContent()); runner.setProperty(MergeContent.MAX_BIN_AGE, "1 sec");
