diff --git a/core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala b/core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala index e29f3fc1b805..a7ed9226c574 100644 --- a/core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala +++ b/core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala @@ -19,7 +19,7 @@ package org.apache.spark.storage import java.io.{File, IOException} import java.nio.file.Files -import java.nio.file.attribute.PosixFilePermission +import java.nio.file.attribute.{PosixFilePermission, PosixFilePermissions} import java.util.UUID import scala.collection.mutable.HashMap @@ -301,9 +301,6 @@ private[spark] class DiskBlockManager( * Create a directory that is writable by the group. * Grant the permission 770 "rwxrwx---" to the directory so the shuffle server can * create subdirs/files within the merge folder. - * TODO: Find out why can't we create a dir using java api with permission 770 - * Files.createDirectories(mergeDir.toPath, PosixFilePermissions.asFileAttribute( - * PosixFilePermissions.fromString("rwxrwx---"))) */ def createDirWithPermission770(dirToCreate: File): Unit = { var attempts = 0 @@ -315,16 +312,13 @@ private[spark] class DiskBlockManager( throw SparkCoreErrors.failToCreateDirectoryError(dirToCreate.getAbsolutePath, maxAttempts) } try { - val builder = new ProcessBuilder().command( - "mkdir", "-p", "-m770", dirToCreate.getAbsolutePath) - val proc = builder.start() - val exitCode = proc.waitFor() + dirToCreate.mkdirs() + Files.setPosixFilePermissions( + dirToCreate.toPath, PosixFilePermissions.fromString("rwxrwx---")) if (dirToCreate.exists()) { created = dirToCreate } - logDebug( - s"Created directory at ${dirToCreate.getAbsolutePath} with permission " + - s"770 and exitCode $exitCode") + logDebug(s"Created directory at ${dirToCreate.getAbsolutePath} with permission 770") } catch { case e: SecurityException => logWarning(s"Failed to create directory ${dirToCreate.getAbsolutePath} " +