pjfanning commented on code in PR #8196:
URL: https://github.com/apache/hadoop/pull/8196#discussion_r2743047136


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/planner/NodePlan.java:
##########
@@ -243,22 +244,11 @@ private static boolean stepClassIsAllowed(String 
className) {
     return false;
   }
 
-  private static List<String> getAllowedPackages() {
-    String packages = CONFIGURATION.get(SUPPORTED_PACKAGES_CONFIG_NAME);
-    return parseCsvLine(packages);
-  }
-
-  static List<String> parseCsvLine(final String line) {
-    if (line == null) {
-      return Collections.emptyList();
-    }
-    List<String> values = new LinkedList<>();
-    for (String value : line.split(",")) {
-      String trimmedValue = value.trim();
-      if (!trimmedValue.isBlank()) {
-        values.add(trimmedValue);
-      }
-    }
-    return values;
+  private static Collection<String> getAllowedPackages() {
+    return CONFIGURATION.getStringCollection(SUPPORTED_PACKAGES_CONFIG_NAME)
+        .stream()
+        .map(String::trim)

Review Comment:
   StringUtils.getStringCollection uses the legacy and discouraged 
java.util.StringTokenizer.
   This StringTokenizer does not trim values - it only omits the delimiter so 
stray whitespace after a comma, for instance, will be returned.
   
   ```
     public static void main(String args[]) {
       String text = "a, b";
       java.util.StringTokenizer tokenizer = new 
java.util.StringTokenizer(text, ",");
       while (tokenizer.hasMoreTokens()) {
         System.out.println("<" + tokenizer.nextToken() + ">");
       }
     }
   ```
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to