sodonnel commented on code in PR #5543:
URL: https://github.com/apache/ozone/pull/5543#discussion_r1385158387


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/helpers/ContainerUtils.java:
##########
@@ -310,13 +311,13 @@ public static long getContainerID(File containerBaseDir) {
   }
 
   public static String getContainerTarName(long containerId) {
-    return "container-" + containerId + ".tar";
+    return "container-" + containerId + "-" + UUID.randomUUID() + ".tar";
   }
 
   public static long retrieveContainerIdFromTarName(String tarName)
       throws IOException {
     assert tarName != null;
-    Pattern pattern = Pattern.compile("container-(\\d+).tar");
+    Pattern pattern = Pattern.compile("container-(\\d+)((-.+.tar)|.tar)");

Review Comment:
   This regex doesn't look correct to me. What are the example patterns you are 
trying to match? Even the original one is wrong as "." (dot) matches any 
character, not the literal dot. You need to escape it to match dot exactly.
   
   It feels like the regex should say match:
   
   * container-
   * a sequence of one or more digits
   * zero or more non-digits (I am not sure what the goal of the `(-.+.tar)` 
bit is
   * .tar
   
   So something like this is perhaps better:
   
   ```
   "container-(\\d+)\\D*\\.tar"
   ```
   
   What are the alternative filenames you are trying to match with the 
`(-.+.tar)` section?



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