mirror of
https://github.com/apache/nifi.git
synced 2025-02-16 23:15:36 +00:00
NIFI-613 just needed to check for line of length 0. Added unit test to prove fail and fix
This commit is contained in:
parent
819b65f7e0
commit
1fb6aa49ba
@ -261,7 +261,7 @@ public class ScanContent extends AbstractProcessor {
|
|||||||
@Override
|
@Override
|
||||||
public SearchTerm<byte[]> nextTerm() throws IOException {
|
public SearchTerm<byte[]> nextTerm() throws IOException {
|
||||||
final String nextLine = reader.readLine();
|
final String nextLine = reader.readLine();
|
||||||
if (nextLine == null) {
|
if (nextLine == null || nextLine.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new SearchTerm<>(nextLine.getBytes("UTF-8"));
|
return new SearchTerm<>(nextLine.getBytes("UTF-8"));
|
||||||
|
@ -18,6 +18,7 @@ package org.apache.nifi.processors.standard;
|
|||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@ -34,6 +35,24 @@ import org.junit.Test;
|
|||||||
|
|
||||||
public class TestScanContent {
|
public class TestScanContent {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBlankLineInDictionaryTextEncoding() throws IOException {
|
||||||
|
final String dictionaryWithBlankLine = "Line1\n\nLine3";
|
||||||
|
final byte[] dictionaryBytes = dictionaryWithBlankLine.getBytes(ScanContent.UTF8);
|
||||||
|
final Path dictionaryPath = Paths.get("target/dictionary");
|
||||||
|
Files.write(dictionaryPath, dictionaryBytes, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
|
||||||
|
|
||||||
|
final TestRunner runner = TestRunners.newTestRunner(new ScanContent());
|
||||||
|
runner.setThreadCount(1);
|
||||||
|
runner.setProperty(ScanContent.DICTIONARY, dictionaryPath.toString());
|
||||||
|
runner.setProperty(ScanContent.DICTIONARY_ENCODING, ScanContent.TEXT_ENCODING);
|
||||||
|
|
||||||
|
runner.enqueue(new byte[0]);
|
||||||
|
runner.run();
|
||||||
|
runner.assertTransferCount(ScanContent.REL_NO_MATCH, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Ignore("This test has a race condition/ordering problem")
|
@Ignore("This test has a race condition/ordering problem")
|
||||||
@Test
|
@Test
|
||||||
public void testBinaryScan() throws IOException {
|
public void testBinaryScan() throws IOException {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user