You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/10/05 09:09:39 UTC

[GitHub] [zookeeper] tamaashu commented on a change in pull request #1478: ZOOKEEPER-3952: Remove commons-lang from ZooKeeper

tamaashu commented on a change in pull request #1478:
URL: https://github.com/apache/zookeeper/pull/1478#discussion_r499450579



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/common/PathTrie.java
##########
@@ -344,4 +345,10 @@ public void clear() {
          }
      }
 
+     private static String[] split(final String path){
+         return Stream.of(path.split("/"))
+                 .filter(t -> (t != null && !t.trim().isEmpty()))

Review comment:
       > is this filter semantically different from commons-lang's `StringUtils.split`? IIRC validation has been done before passed into `PathTrie` or at least this method seems more than just split path but also validate and filter things.
   
   If we split a path like "/node1/node2" with StringUtils.split at "/" we get the following: ["node1", "node2"].
   If we do the same with String.split we get ["", "node1", "node2"], because it recognizes an empty string before the first "/".
   The filter provides a solution to not have the first empty string, only the rest of the elements.




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