ChrisSamo632 commented on a change in pull request #4854:
URL: https://github.com/apache/nifi/pull/4854#discussion_r589285916



##########
File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-properties-loader/src/main/java/org/apache/nifi/properties/NiFiPropertiesLoader.java
##########
@@ -174,6 +177,18 @@ ProtectedNiFiProperties 
readProtectedPropertiesFromDisk(File file) {
             rawProperties.load(inStream);
             logger.info("Loaded {} properties from {}", rawProperties.size(), 
file.getAbsolutePath());
 
+            // Trim whitespace from each property. If property is multi-line, 
remove anything after the first line break.
+            Set<String> keys = rawProperties.stringPropertyNames();
+            Iterator<String> itr = keys.iterator();
+            while(itr.hasNext()){
+                String key = itr.next();
+                String prop = rawProperties.getProperty(key);
+                if(!prop.isEmpty()){
+                    prop = 
Pattern.compile("\\s+$").matcher(prop).replaceFirst("");

Review comment:
       Probably better to define the Pattern once as a class-level static final 
field *or* use the String class' `replace` such as `prop.replace("\\s+$", "")`, 
although I'd guess using the pre-compiled Pattern would be slightly more 
efficient... but this code is probably only run once at startup anyway so it's 
unlikely a big deal (but I'd still prefer Pattern not to be compiled every time 
within the `while` loop)




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to