Shockang commented on a change in pull request #33101:
URL: https://github.com/apache/spark/pull/33101#discussion_r661587935
##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -310,15 +306,17 @@ private[spark] object Utils extends Logging {
while (dir == null) {
attempts += 1
if (attempts > maxAttempts) {
- throw new IOException("Failed to create a temp directory (under " +
root + ") after " +
- maxAttempts + " attempts!")
+ throw new IOException(s"Failed to create a temp directory (under
$root) after " +
+ s"$maxAttempts attempts!")
}
try {
dir = new File(root, namePrefix + "-" + UUID.randomUUID.toString)
- if (dir.exists() || !dir.mkdirs()) {
- dir = null
- }
- } catch { case e: SecurityException => dir = null; }
+ // SPARK-35907 Instead of File#mkdirs, Files#createDirectories is
expected.
+ Files.createDirectories(dir.toPath)
+ } catch { case e: Exception =>
Review comment:
I intended to write the code like this:
`case e @ (_ : FileAlreadyExistsException | _ : IOException | _ :
SecurityException) =>`
but considering that the above method: createDirectory(File) also uses
Exception, it would be better to keep the same here.And the code is not very
concise.
--
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]