This is an automated email from the ASF dual-hosted git repository. srowen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 5cb5d1fa66a [SPARK-39204][CORE] Change `Utils.createTempDir` and `Utils.createDirectory` call the same logic method in `JavaUtils` 5cb5d1fa66a is described below commit 5cb5d1fa66ad9d6e94beb17d3fda3a8f220bc371 Author: yangjie01 <yangji...@baidu.com> AuthorDate: Sat May 21 09:37:42 2022 -0500 [SPARK-39204][CORE] Change `Utils.createTempDir` and `Utils.createDirectory` call the same logic method in `JavaUtils` ### What changes were proposed in this pull request? SPARK-39102 introduces two methods `createTempDir` and `createDirectory` into `JavaUtils`, which have the same logic as the method with the same name in `Utils`, in order to continuously ensure they have the same logic, this pr is change `Utils.createTempDir` and `Utils.createDirectory` call the same logic method in `JavaUtils`. ### Why are the changes needed? Keep only one `createTempDir()` and `createDirectory()` logic in Spark. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? - Pass GitHub Action. Closes #36611 from LuciferYang/SPARK-39204-2. Authored-by: yangjie01 <yangji...@baidu.com> Signed-off-by: Sean Owen <sro...@gmail.com> --- .../main/scala/org/apache/spark/util/Utils.scala | 27 ++-------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala index 24b3d2b6191..cf46a3d34c4 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -308,28 +308,7 @@ private[spark] object Utils extends Logging { * newly created, and is not marked for automatic deletion. */ def createDirectory(root: String, namePrefix: String = "spark"): File = { - var attempts = 0 - val maxAttempts = MAX_DIR_CREATION_ATTEMPTS - var dir: File = null - while (dir == null) { - attempts += 1 - if (attempts > maxAttempts) { - throw new IOException("Failed to create a temp directory (under " + root + ") after " + - maxAttempts + " attempts!") - } - try { - dir = new File(root, namePrefix + "-" + UUID.randomUUID.toString) - // SPARK-35907: - // This could throw more meaningful exception information if directory creation failed. - Files.createDirectories(dir.toPath) - } catch { - case e @ (_ : IOException | _ : SecurityException) => - logError(s"Failed to create directory $dir", e) - dir = null - } - } - - dir.getCanonicalFile + JavaUtils.createDirectory(root, namePrefix) } /** @@ -339,9 +318,7 @@ private[spark] object Utils extends Logging { def createTempDir( root: String = System.getProperty("java.io.tmpdir"), namePrefix: String = "spark"): File = { - val dir = createDirectory(root, namePrefix) - ShutdownHookManager.registerShutdownDeleteDir(dir) - dir + JavaUtils.createTempDir(root, namePrefix) } /** --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org