Shockang commented on a change in pull request #33101:
URL: https://github.com/apache/spark/pull/33101#discussion_r661579528
##########
File path: core/src/main/scala/org/apache/spark/util/Utils.scala
##########
@@ -285,13 +285,10 @@ private[spark] object Utils extends Logging {
*/
def createDirectory(dir: File): Boolean = {
try {
- // This sporadically fails - not sure why ... !dir.exists() &&
!dir.mkdirs()
- // So attempting to create and then check if directory was created or
not.
- dir.mkdirs()
- if ( !dir.exists() || !dir.isDirectory) {
- logError(s"Failed to create directory " + dir)
- }
- dir.isDirectory
+ // SPARK-35907
+ // This could throw more meaningful exception information if directory
creation failed.
+ Files.createDirectories(dir.toPath)
+ true
Review comment:
In some extreme scenarios, Files.createDirectories would fail silently.
In this case, we can submit an issue to the JDK official. ︿( ̄︶ ̄)︿ The purpose
of using this method is to provide better exception handling mechanism, but it
should not be at the cost of reducing security, so I take your
suggestion.Thanks a lot. (*^▽^*)
--
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]