Skip to content

Commit 051d4b5

Browse files
committed
check dir existing and return empty List as default.
1 parent 2b91a9c commit 051d4b5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,15 @@ private[spark] object Utils extends Logging {
659659
}
660660

661661
private def listFilesSafely(file: File): Seq[File] = {
662-
val files = file.listFiles()
663-
if (files == null) {
664-
throw new IOException("Failed to list files for dir: " + file)
662+
if (file.exists()) {
663+
val files = file.listFiles()
664+
if (files == null) {
665+
throw new IOException("Failed to list files for dir: " + file)
666+
}
667+
files
668+
} else {
669+
List()
665670
}
666-
files
667671
}
668672

669673
/**

0 commit comments

Comments
 (0)