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_r305183247
 
 

 ##########
 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;
 
 Review comment:
   Since PropertyDescriptor is passed, we can return its default value instead 
of null. Then callers don't have to check if the returned character is null.

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