pvillard31 commented on code in PR #8229: URL: https://github.com/apache/nifi/pull/8229#discussion_r1452627532
########## nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java: ########## @@ -619,18 +632,83 @@ public NifiCsvListReader(Reader reader, CsvPreference preferences) { super(reader, preferences); } - @Override - public List<Object> read(CellProcessor... processors) throws IOException { + public List<Object> read(boolean getAllViolations, CellProcessor... processors) throws IOException { if( processors == null ) { throw new NullPointerException("Processors should not be null"); } if( readRow() ) { - super.executeProcessors(new ArrayList<Object>(getColumns().size()), processors); + executeProcessors(new ArrayList<Object>(getColumns().size()), processors, getAllViolations); return new ArrayList<Object>(getColumns()); Review Comment: While I agree specifying the type is not required, isn't it making the code more readable? ########## nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java: ########## @@ -619,18 +632,83 @@ public NifiCsvListReader(Reader reader, CsvPreference preferences) { super(reader, preferences); } - @Override - public List<Object> read(CellProcessor... processors) throws IOException { + public List<Object> read(boolean getAllViolations, CellProcessor... processors) throws IOException { if( processors == null ) { throw new NullPointerException("Processors should not be null"); } if( readRow() ) { - super.executeProcessors(new ArrayList<Object>(getColumns().size()), processors); + executeProcessors(new ArrayList<Object>(getColumns().size()), processors, getAllViolations); return new ArrayList<Object>(getColumns()); } return null; // EOF } + protected List<Object> executeProcessors(List<Object> processedColumns, CellProcessor[] processors, boolean getAllViolations) { + this.executeCellProcessors(processedColumns, getColumns(), processors, getLineNumber(), getRowNumber(), getAllViolations); + return processedColumns; + } + + private void executeCellProcessors(final List<Object> destination, final List<?> source, + final CellProcessor[] processors, final int lineNo, final int rowNo, boolean getAllViolations) { + + if( destination == null ) { + throw new NullPointerException("destination should not be null"); + } else if( source == null ) { + throw new NullPointerException("source should not be null"); + } else if( processors == null ) { + throw new NullPointerException("processors should not be null"); + } + + // the context used when cell processors report exceptions + final CsvContext context = new CsvContext(lineNo, rowNo, 1); + context.setRowSource(new ArrayList<Object>(source)); + + if( source.size() != processors.length ) { + throw new SuperCsvException(String.format( + "The number of columns to be processed (%d) must match the number of CellProcessors (%d): check that the number" + + " of CellProcessors you have defined matches the expected number of columns being read/written", + source.size(), processors.length), context); + } + + destination.clear(); + + List<String> errors = new ArrayList<String>(); Review Comment: While I agree specifying the type is not required, isn't it making the code more readable? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org