ijokarumawak commented on a change in pull request #3504: NIFI-6318: Support EL 
in CSV formatting properties
URL: https://github.com/apache/nifi/pull/3504#discussion_r305182806
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-standard-record-utils/src/main/java/org/apache/nifi/csv/CSVUtils.java
 ##########
 @@ -190,57 +208,91 @@ public static CSVFormat createCSVFormat(final 
PropertyContext context) {
         }
     }
 
-    private static char getUnescapedChar(final PropertyContext context, final 
PropertyDescriptor property) {
-        return 
StringEscapeUtils.unescapeJava(context.getProperty(property).getValue()).charAt(0);
+    private static Character getCharUnescapedJava(final PropertyContext 
context, final PropertyDescriptor property, final Map<String, String> 
variables) {
+        String value = 
context.getProperty(property).evaluateAttributeExpressions(variables).getValue();
+
+        if (value != null) {
+            String unescaped = unescapeJava(value);
+            if (unescaped.length() == 1) {
+                return unescaped.charAt(0);
+            }
+        }
+
+        LOG.warn("'{}' property evaluated to an invalid value: \"{}\". It must 
be a single character. The property value will be skipped.", 
property.getName(), value);
+        return null;
     }
 
-    private static char getChar(final PropertyContext context, final 
PropertyDescriptor property) {
-        return 
CSVUtils.unescape(context.getProperty(property).getValue()).charAt(0);
+    private static Character getCharUnescaped(final PropertyContext context, 
final PropertyDescriptor property, final Map<String, String> variables) {
+        String value = 
context.getProperty(property).evaluateAttributeExpressions(variables).getValue();
+
+        if (value != null) {
+            String unescaped = unescape(value);
+            if (unescaped.length() == 1) {
+                return unescaped.charAt(0);
+            }
+        }
+
+        LOG.warn("'{}' property evaluated to an invalid value: \"{}\". It must 
be a single character. The property value will be skipped.", 
property.getName(), value);
 
 Review comment:
   Same as above, `skipped` vs `ignored`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to