ayushtkn commented on code in PR #5669:
URL: https://github.com/apache/hadoop/pull/5669#discussion_r1198937053


##########
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestCheck.java:
##########
@@ -116,6 +116,16 @@ public void validIdentifierInvalid3() throws Exception {
     Check.validIdentifier("1", 1, "");
   }
 
+  @Test(expected = IllegalArgumentException.class)
+  public void validIdentifierInvalid4() throws Exception {
+    Check.validIdentifier("`a", 1, "");
+  }
+
+  @Test(expected = IllegalArgumentException.class)
+  public void validIdentifierInvalid5() throws Exception {
+    Check.validIdentifier("[a", 1, "");
+  }
+

Review Comment:
   Debugging further. It is because you specified max length as 1, change it to 
2 and it should work the way we want. Else it is still IAE
   ```
   java.lang.IllegalArgumentException: [] = [`a] exceeds max len [1]
   
        at org.apache.hadoop.lib.util.Check.validIdentifier(Check.java:129)
        at 
org.apache.hadoop.lib.util.TestCheck.validIdentifierInvalid4(TestCheck.java:121)
   ```
   
   So increase the param to 2.
   
   Btw. there is one more bug in the code here:
   ```
         throw new IllegalArgumentException(
           MessageFormat.format("[{0}] = [{1}] must be '{2}'", name, value, 
IDENTIFIER_PATTERN_STR));
   ```
   the value of {2} doesn't get printed mostly because of single quotes, 
removing that fixes that, in case interested, yo u can raise a ticket and fix 
it as well, will be happy to review :-) 
   



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