NIFI-3556 Fixed ValidateCsv schema parsing

Fixed schema parsing on comma boundaries.

This closes #1570.

Signed-off-by: James Wing <jvwing@gmail.com>
This commit is contained in:
Pierre Villard 2017-03-07 19:48:00 +01:00 committed by James Wing
parent 27afd2e0cc
commit 37e9c5efc7
2 changed files with 10 additions and 1 deletions

View File

@ -250,15 +250,17 @@ public class ValidateCsv extends AbstractProcessor {
private String setProcessor(String remaining, List<CellProcessor> processorsList) { private String setProcessor(String remaining, List<CellProcessor> processorsList) {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
String inputString = remaining;
int i = 0; int i = 0;
int opening = 0; int opening = 0;
int closing = 0; int closing = 0;
while(buffer.length() != remaining.length()) { while(buffer.length() != inputString.length()) {
char c = remaining.charAt(i); char c = remaining.charAt(i);
i++; i++;
if(opening == 0 && c == ',') { if(opening == 0 && c == ',') {
if(i == 1) { if(i == 1) {
inputString = inputString.substring(1);
continue; continue;
} }
break; break;

View File

@ -271,4 +271,11 @@ public class TestValidateCsv {
runner.assertNotValid(); runner.assertNotValid();
} }
@Test
public void testParseSchemaCommaBoundary() {
final TestRunner runner = TestRunners.newTestRunner(new ValidateCsv());
runner.setProperty(ValidateCsv.SCHEMA, "Null(),Null");
runner.assertValid();
}
} }