ddanielr commented on code in PR #5764:
URL: https://github.com/apache/accumulo/pull/5764#discussion_r2232510071


##########
core/src/main/java/org/apache/accumulo/core/conf/cluster/ClusterConfigParser.java:
##########
@@ -44,12 +44,11 @@
 
 public class ClusterConfigParser {
 
-  private static final Pattern GROUP_NAME_PATTERN =
-      Pattern.compile("^[a-zA-Z_]{1,}[a-zA-Z0-9_]{0,}$");
+  private static final Pattern GROUP_NAME_PATTERN = 
Pattern.compile("^[a-zA-Z_]+[a-zA-Z0-9_]*$");

Review Comment:
   Original changes looked good. Moved the underscore match so that a resource 
group name of `_` is not considered valid
   
   ```suggestion
     private static final Pattern GROUP_NAME_PATTERN = 
Pattern.compile("^([a-zA-Z]_?)+[a-zA-Z0-9_]*$");
   ```



##########
core/src/test/java/org/apache/accumulo/core/data/ResourceGroupIdTest.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.data;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+public class ResourceGroupIdTest {
+  @Test
+  public void testIllegalIds() {
+    assertThrows(IllegalArgumentException.class, () -> ResourceGroupId.of(""));
+    assertThrows(IllegalArgumentException.class, () -> ResourceGroupId.of(" 
"));
+    assertThrows(IllegalArgumentException.class, () -> 
ResourceGroupId.of("\t"));

Review Comment:
   A resource group name of `_` should probably not be valid.
   ```suggestion
       assertThrows(IllegalArgumentException.class, () -> 
ResourceGroupId.of("\t"));
       assertThrows(IllegalArgumentException.class, () -> 
ResourceGroupId.of("_"));
   ```



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