exceptionfactory commented on code in PR #9490:
URL: https://github.com/apache/nifi/pull/9490#discussion_r1829816649


##########
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/configuration/StandardConfigurationProvider.java:
##########
@@ -64,23 +65,18 @@ public StandardConfigurationProvider(final Map<String, 
String> environmentVariab
 
     /**
      * Get additional arguments for application command from Bootstrap 
Properties starting with java.arg
+     * Return the list sorted by java.arg names (not values) in ascending 
alphabetical order

Review Comment:
   ```suggestion
        * Return the list sorted by java.arg names in ascending alphabetical 
order
   ```



##########
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/configuration/StandardConfigurationProvider.java:
##########
@@ -64,23 +65,18 @@ public StandardConfigurationProvider(final Map<String, 
String> environmentVariab
 
     /**
      * Get additional arguments for application command from Bootstrap 
Properties starting with java.arg
+     * Return the list sorted by java.arg names (not values) in ascending 
alphabetical order
      *
      * @return Additional arguments
      */
     @Override
     public List<String> getAdditionalArguments() {
-        final List<String> additionalArguments = new ArrayList<>();
-
-        for (final String propertyName : 
bootstrapProperties.stringPropertyNames()) {
-            if 
(propertyName.startsWith(BootstrapProperty.JAVA_ARGUMENT.getProperty())) {
-                final String additionalArgument = 
bootstrapProperties.getProperty(propertyName);
-                if (!additionalArgument.isBlank()) {
-                    additionalArguments.add(additionalArgument);
-                }
-            }
-        }
-
-        return additionalArguments;
+        return new 
ArrayList<>(bootstrapProperties.stringPropertyNames()).stream()
+                .filter(name -> 
name.startsWith(BootstrapProperty.JAVA_ARGUMENT.getProperty()))
+                .filter(name -> 
!bootstrapProperties.getProperty(name).isBlank())
+                .sorted()
+                .map(bootstrapProperties::getProperty)
+                .collect(Collectors.toCollection(ArrayList::new));

Review Comment:
   It looks like this can be simplified, avoiding the new to create a new 
wrapping `ArrayList`, and replacing the `collect()` method to a simple 
`toList()`.



##########
nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/configuration/StandardConfigurationProvider.java:
##########
@@ -64,23 +65,18 @@ public StandardConfigurationProvider(final Map<String, 
String> environmentVariab
 
     /**
      * Get additional arguments for application command from Bootstrap 
Properties starting with java.arg
+     * Return the list sorted by java.arg names (not values) in ascending 
alphabetical order
      *
      * @return Additional arguments
      */
     @Override
     public List<String> getAdditionalArguments() {
-        final List<String> additionalArguments = new ArrayList<>();
-
-        for (final String propertyName : 
bootstrapProperties.stringPropertyNames()) {
-            if 
(propertyName.startsWith(BootstrapProperty.JAVA_ARGUMENT.getProperty())) {
-                final String additionalArgument = 
bootstrapProperties.getProperty(propertyName);
-                if (!additionalArgument.isBlank()) {
-                    additionalArguments.add(additionalArgument);
-                }
-            }
-        }
-
-        return additionalArguments;
+        return new 
ArrayList<>(bootstrapProperties.stringPropertyNames()).stream()
+                .filter(name -> 
name.startsWith(BootstrapProperty.JAVA_ARGUMENT.getProperty()))
+                .filter(name -> 
!bootstrapProperties.getProperty(name).isBlank())

Review Comment:
   Minor optimization, but it seems better to add the not blank filter after 
the `map()` call.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to