keith-turner commented on code in PR #5893:
URL: https://github.com/apache/accumulo/pull/5893#discussion_r2364846777


##########
core/src/main/java/org/apache/accumulo/core/data/ResourceGroupId.java:
##########
@@ -43,16 +43,23 @@ public class ResourceGroupId extends 
AbstractId<ResourceGroupId> {
 
   private ResourceGroupId(String canonical) {
     super(canonical);
-    if (!GROUP_NAME_PATTERN.matcher(canonical).matches()) {
-      throw new IllegalArgumentException(
-          "Group name: " + canonical + " contains invalid characters");
+    validateGroupName(canonical);
+  }
+
+  /**
+   * @throws IllegalArgumentException if the group name is invalid
+   */
+  public static void validateGroupName(String groupName) {
+    if (!GROUP_NAME_PATTERN.matcher(groupName).matches()) {
+      throw new IllegalArgumentException("Group name '" + groupName
+          + "' is invalid. Valid names must match the pattern: " + 
GROUP_NAME_PATTERN.pattern());

Review Comment:
   Having a public method that only does validation would be useful if there 
was a performance need to avoid allocating a object.  However w/ the caching 
that is done, that probably mitigates any problems w/ calling `of()` frequently 
as that avoids allocation.  



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

Reply via email to