From 8e4948322e0e799a5bc216343c201737ecf6bc18 Mon Sep 17 00:00:00 2001 From: Mike Thomsen Date: Sun, 6 Dec 2020 08:37:34 -0500 Subject: [PATCH] NIFI-8074 Switched ReplaceText to use line by line evaluation as its default evaluation mode. This closes #4711 Signed-off-by: Mike Thomsen --- .../java/org/apache/nifi/processors/standard/ReplaceText.java | 2 +- .../org/apache/nifi/processors/standard/TestReplaceText.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ReplaceText.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ReplaceText.java index c3d87f12c8..fb0cbb8184 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ReplaceText.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ReplaceText.java @@ -172,7 +172,7 @@ public class ReplaceText extends AbstractProcessor { .description("Run the 'Replacement Strategy' against each line separately (Line-by-Line) or buffer the entire file " + "into memory (Entire Text) and run against that.") .allowableValues(LINE_BY_LINE, ENTIRE_TEXT) - .defaultValue(ENTIRE_TEXT) + .defaultValue(LINE_BY_LINE) .required(true) .build(); diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java index 9dac00f58d..341b75e911 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestReplaceText.java @@ -770,6 +770,7 @@ public class TestReplaceText { runner.setProperty(ReplaceText.SEARCH_VALUE, "[123]"); runner.setProperty(ReplaceText.MAX_BUFFER_SIZE, "1 b"); runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "${abc}"); + runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.ENTIRE_TEXT); final Map attributes = new HashMap<>(); attributes.put("abc", "Good"); @@ -823,6 +824,7 @@ public class TestReplaceText { final TestRunner runner = getRunner(); runner.setProperty(ReplaceText.SEARCH_VALUE, "(?s)(^.*)"); runner.setProperty(ReplaceText.REPLACEMENT_VALUE, "attribute header\n\n${filename}\n\ndata header\n\n$1\n\nfooter"); + runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.ENTIRE_TEXT); final Map attributes = new HashMap<>(); attributes.put("filename", "abc.txt"); @@ -879,6 +881,7 @@ public class TestReplaceText { // leave the default regex settings final TestRunner runner = getRunner(); runner.setProperty(ReplaceText.REPLACEMENT_VALUE, defaultValue); + runner.setProperty(ReplaceText.EVALUATION_MODE, ReplaceText.ENTIRE_TEXT); final Map attributes = new HashMap<>(); runner.enqueue(("original-text-line-1" + System.lineSeparator() + "original-text-line-2").getBytes(StandardCharsets.UTF_8), attributes);