dtspence commented on code in PR #3549:
URL: https://github.com/apache/accumulo/pull/3549#discussion_r1245231498


##########
core/src/main/java/org/apache/accumulo/core/metadata/ValidationUtil.java:
##########
@@ -62,9 +62,12 @@ public static void validateRFileName(String fileName) {
 
   public static void validateFileName(String fileName) {
     Objects.requireNonNull(fileName);
-    if (!fileName.matches("[\\dA-Za-z._-]+")) {
-      throw new IllegalArgumentException(
-          "Provided filename (" + fileName + ") contains invalid characters.");
+    for (int i = 0; i < fileName.length(); i++) {
+      final char ch = fileName.charAt(i);
+      if (!(Character.isLetterOrDigit(ch) || ch == '-' || ch == '.' || ch == 
'_')) {
+        throw new IllegalArgumentException(
+            "Provided filename (" + fileName + ") contains invalid 
characters.");
+      }

Review Comment:
   I initially tested a similar version to the suggested code (and re-verified 
with the suggested code). In the benchmark tests I used a for-loop version ran 
in roughly half the time and selected based on performance. I can update to use 
the more readable version and/or analyze further if needed.



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