Freedom9339 commented on code in PR #8362:
URL: https://github.com/apache/nifi/pull/8362#discussion_r1664136642


##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ValidateCsv.java:
##########
@@ -458,155 +473,147 @@ public void onTrigger(final ProcessContext context, 
final ProcessSession session
         final CsvPreference csvPref = getPreference(context, flowFile);
         final boolean header = context.getProperty(HEADER).asBoolean();
         final ComponentLog logger = getLogger();
-        final String schema = 
context.getProperty(SCHEMA).evaluateAttributeExpressions(flowFile).getValue();
-        final CellProcessor[] cellProcs = this.parseSchema(schema);
-        final boolean isWholeFFValidation = 
context.getProperty(VALIDATION_STRATEGY).getValue().equals(VALIDATE_WHOLE_FLOWFILE.getValue());
+        String schema = 
context.getProperty(SCHEMA).evaluateAttributeExpressions(flowFile).getValue();
+        CellProcessor[] cellProcs = null;
+        if (schema != null) {
+            cellProcs = this.parseSchema(schema);
+        }
+        final String validationStrategy = 
context.getProperty(VALIDATION_STRATEGY).getValue();
+        final boolean isWholeFFValidation = 
!validationStrategy.equals(VALIDATE_LINES_INDIVIDUALLY.getValue());
         final boolean includeAllViolations = 
context.getProperty(INCLUDE_ALL_VIOLATIONS).asBoolean();
 
-        final AtomicReference<Boolean> valid = new 
AtomicReference<Boolean>(true);
+        boolean valid = true;
+        int okCount = 0;
+        int totalCount = 0;
+        FlowFile invalidFF = null;
+        FlowFile validFF = null;
+        String validationError = null;
         final AtomicReference<Boolean> isFirstLineValid = new 
AtomicReference<Boolean>(true);
         final AtomicReference<Boolean> isFirstLineInvalid = new 
AtomicReference<Boolean>(true);
-        final AtomicReference<Integer> okCount = new 
AtomicReference<Integer>(0);
-        final AtomicReference<Integer> totalCount = new 
AtomicReference<Integer>(0);
-        final AtomicReference<FlowFile> invalidFF = new 
AtomicReference<FlowFile>(null);
-        final AtomicReference<FlowFile> validFF = new 
AtomicReference<FlowFile>(null);
-        final AtomicReference<String> validationError = new 
AtomicReference<String>(null);
 
         if (!isWholeFFValidation) {
-            invalidFF.set(session.create(flowFile));
-            validFF.set(session.create(flowFile));
+            invalidFF = session.create(flowFile);
+            validFF = session.create(flowFile);
+        }
+
+        InputStream stream;
+        if (context.getProperty(CSV_SOURCE_ATTRIBUTE).isSet()) {
+            stream = new 
ByteArrayInputStream(flowFile.getAttribute(context.getProperty(CSV_SOURCE_ATTRIBUTE).getValue()).getBytes(StandardCharsets.UTF_8));

Review Comment:
   Done.



-- 
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

Reply via email to