You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/11/05 18:01:11 UTC

[GitHub] [druid] jihoonson commented on a change in pull request #11879: Migrate File.mkdirs to FileUtils.mkdirp.

jihoonson commented on a change in pull request #11879:
URL: https://github.com/apache/druid/pull/11879#discussion_r743873821



##########
File path: core/src/main/java/org/apache/druid/java/util/common/FileUtils.java
##########
@@ -379,6 +379,27 @@ public static File createTempDir(@Nullable final String prefix)
     }
   }
 
+  /**
+   * Create "directory" and all intermediate directories as needed. If the directory is successfully created, or already
+   * exists, returns quietly. Otherwise, throws an IOException.
+   *
+   * Simpler to use than {@link File#mkdirs()}, and more reliable since it is safe from races where two threads try

Review comment:
       This method seems similar to `org.apache.commons.io.FileUtils.forceMkdir()` besides this handling for the race, and so perhaps we can fix the anti-pattern if we have and use it instead of adding a new method?

##########
File path: core/src/main/java/org/apache/druid/java/util/common/FileUtils.java
##########
@@ -379,6 +379,27 @@ public static File createTempDir(@Nullable final String prefix)
     }
   }
 
+  /**
+   * Create "directory" and all intermediate directories as needed. If the directory is successfully created, or already
+   * exists, returns quietly. Otherwise, throws an IOException.
+   *
+   * Simpler to use than {@link File#mkdirs()}, and more reliable since it is safe from races where two threads try

Review comment:
       Do we have this issue today? Or is this a future-proof? The race in creating directory sounds like an anti-pattern because.. why not using a single thread to prepare the directory and then letting other threads write their files without race?




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org