mirror of
https://github.com/apache/nifi.git
synced 2025-02-16 15:06:00 +00:00
NIFI-975 Fixing NullPointerException when one of the delimiters is not provided when using the Text strategy
This commit is contained in:
parent
14eaeeb1ee
commit
5764e89293
@ -641,7 +641,10 @@ public class MergeContent extends BinFiles {
|
|||||||
if (wrapper != null) {
|
if (wrapper != null) {
|
||||||
final FlowFile flowFile = wrapper.getFlowFile();
|
final FlowFile flowFile = wrapper.getFlowFile();
|
||||||
if (flowFile != null) {
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,6 +256,27 @@ public class TestMergeContent {
|
|||||||
bundle.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), "application/plain-text");
|
bundle.assertAttributeEquals(CoreAttributes.MIME_TYPE.key(), "application/plain-text");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
@Test
|
||||||
public void testSimpleBinaryConcatWithFileDelimiters() throws IOException, InterruptedException {
|
public void testSimpleBinaryConcatWithFileDelimiters() throws IOException, InterruptedException {
|
||||||
final TestRunner runner = TestRunners.newTestRunner(new MergeContent());
|
final TestRunner runner = TestRunners.newTestRunner(new MergeContent());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user