symious commented on code in PR #3342:
URL: https://github.com/apache/ozone/pull/3342#discussion_r862469706


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/net/NetUtils.java:
##########
@@ -149,4 +149,28 @@ public static List<Node> getAncestorList(NetworkTopology 
topology,
     }
     return ancestorList;
   }
+
+  /**
+   * Ensure {@link NetConstants#PATH_SEPARATOR_STR} is added to the suffix of
+   * the path.
+   * @param path path to add suffix
+   * @return the normalised path
+   * If <i>path</i>is empty, then {@link NetConstants#ROOT} is returned
+   */
+  public static String addSuffix(String path) {
+    if (path == null) {
+      return null;
+    }
+
+    int len = path.length();
+    if (len == 0) {
+      return NetConstants.PATH_SEPARATOR_STR;
+    }
+
+    if (path.charAt(len - 1) != NetConstants.PATH_SEPARATOR) {
+      return path + NetConstants.PATH_SEPARATOR_STR;
+    }
+
+    return path;

Review Comment:
   Yes, the new code is more succinct, thanks for the advice.



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