cku328 commented on a change in pull request #812:
URL: https://github.com/apache/hadoop-ozone/pull/812#discussion_r414884358



##########
File path: 
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java
##########
@@ -196,6 +196,27 @@ public static void verifyResourceName(String... 
resourceNames) {
     }
   }
 
+  /**
+   * verifies that key name is a valid name.
+   *
+   * @param keyName key name to be validated
+   *
+   * @throws IllegalArgumentException
+   */
+  public static void verifyKeyName(String keyName) {
+    if (keyName == null) {
+      throw new IllegalArgumentException("Key name is null");
+    }
+    for (int index = 0; index < keyName.length(); index++) {
+      char currChar = keyName.charAt(index);
+      if (!(Character.toString(currChar)
+              .matches(OzoneConsts.KEYNAME_AVOID_CHARACTERS_REGEX))){

Review comment:
       Thanks @adoroszlai for the comment.
   Checking each character independently with regular expressions to know 
exactly which one is not allowed. But I feel the same way, independently check 
each character is expensive, so I modified it to use full-string to check.




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



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

Reply via email to