Github user markap14 commented on a diff in the pull request: https://github.com/apache/nifi/pull/280#discussion_r56327650 --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/SplitText.java --- @@ -143,72 +199,82 @@ protected void init(final ProcessorInitializationContext context) { return properties; } - private int readLines(final InputStream in, final int maxNumLines, final OutputStream out, final boolean keepAllNewLines) throws IOException { + private int readLines(final InputStream in, final int maxNumLines, final long maxByteCount, final OutputStream out) throws IOException { int numLines = 0; + long totalBytes = 0L; for (int i = 0; i < maxNumLines; i++) { - final long bytes = countBytesToSplitPoint(in, out, keepAllNewLines || (i != maxNumLines - 1)); + final long bytes = countBytesToSplitPoint(in, out, totalBytes, maxByteCount); + totalBytes += bytes; if (bytes <= 0) { return numLines; } - numLines++; + if (totalBytes >= maxByteCount && numLines > maxNumLines) { --- End diff -- The logic here appears to be incorrect. numLines is incremented for each iteration of the loop (unless we return before it is incremented). This means that numLines <= i The loop's condition indicates i < maxNumLines So numLines <= i < maxNumLines So it is always the case that numLines < maxNumLines, so this condition will never be satisfied because numLines will never be > maxNumLines Now, looking through the code and doing a bit of testing, this does not appear to return an incorrect result, since countBytesToSplitPoint will handle the logic appropriately itself, but this should be fixed before it is merged.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---