ctubbsii commented on code in PR #3511:
URL: https://github.com/apache/accumulo/pull/3511#discussion_r1237652230


##########
core/src/main/java/org/apache/accumulo/core/metadata/ValidationUtil.java:
##########
@@ -52,8 +56,13 @@ public static Path validate(Path path) {
   }
 
   public static void validateRFileName(String fileName) {
-    Objects.requireNonNull(fileName);
-    // TODO: In 3.0.0 validate that filename starts with FilePrefix
+    Preconditions.checkArgument(!StringUtils.isEmpty(fileName),
+        "Provided filename is null or empty.");
+
+    // This will make sure the prefix is valid and throw an 
IllegalArgumentException if the prefix
+    // does not match a known value
+    var unused = FilePrefix.fromPrefix(fileName.substring(0, 1));

Review Comment:
   Naming the variable "unused" doesn't actually prevent some tools from 
reporting that it is unused. Could do some kind of assertion check here (`if 
(FilePrefix.fromPrefix(...) == null) { throw .... ; }`). Depending on what it 
returns, this check could probably be combined with the subsequent `if` 
statement that verifies it the file name `.endsWith` the expected stuff.
   
   Or just add a trivial `void` method in `FilePrefix` called `validatePrefix` 
that works similarly to `fromPrefix`, but doesn't have an expected return 
statement (and maybe does the substring for you).



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