[ https://issues.apache.org/jira/browse/HDFS-14935?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16959623#comment-16959623 ]
Lisheng Sun edited comment on HDFS-14935 at 10/25/19 9:59 AM: -------------------------------------------------------------- hi [~ayushtkn] this Jira is used to optimize code and no need to write repetitive code. use existing code as follow: {code:java} scope = NodeBase.normalize(scope); public static String normalize(String path) { if (path == null) { throw new IllegalArgumentException( "Network Location is null "); } if (path.length() == 0) { return ROOT; } if (path.charAt(0) != PATH_SEPARATOR) { throw new IllegalArgumentException( "Network Location path does not start with " +PATH_SEPARATOR_STR+ ": "+path); } int len = path.length(); if (path.charAt(len-1) == PATH_SEPARATOR) { return path.substring(0, len-1); } return path; } {code} was (Author: leosun08): hi [~ayushtkn] this Jira is used to optimize code and no need to write repetitive code. use existing code as follow: {code:java} scope = NodeBase.normalize(scope); public static String normalize(String path) { if (path == null) { throw new IllegalArgumentException( "Network Location is null "); } if (path.length() == 0) { return ROOT; } if (path.charAt(0) != PATH_SEPARATOR) { throw new IllegalArgumentException( "Network Location path does not start with " +PATH_SEPARATOR_STR+ ": "+path); } int len = path.length(); if (path.charAt(len-1) == PATH_SEPARATOR) { return path.substring(0, len-1); } return path; } {code} https://issues.apache.org/jira/secure/attachment/12984010/HDFS-14935.002.patch > Optimize DFSNetworkTopology#isNodeInScope > ----------------------------------------- > > Key: HDFS-14935 > URL: https://issues.apache.org/jira/browse/HDFS-14935 > Project: Hadoop HDFS > Issue Type: Improvement > Reporter: Lisheng Sun > Assignee: Lisheng Sun > Priority: Major > Attachments: HDFS-14935.001.patch, HDFS-14935.002.patch > > -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org