diff options
author | Matei Zaharia <matei.zaharia@gmail.com> | 2013-09-09 20:16:19 -0700 |
---|---|---|
committer | Matei Zaharia <matei.zaharia@gmail.com> | 2013-09-09 20:16:19 -0700 |
commit | c81377b9eda431f9298045d613d0e46301b08c63 (patch) | |
tree | 6bcd1d9996166234a103a24ce5121acea6e9281d /core/src/main | |
parent | 61d2a010e1b2d25616c378185606e6ba7c2b916b (diff) | |
parent | fdb8b0eec3e423e601de8c79658c4644717f4e05 (diff) | |
download | spark-c81377b9eda431f9298045d613d0e46301b08c63.tar.gz spark-c81377b9eda431f9298045d613d0e46301b08c63.tar.bz2 spark-c81377b9eda431f9298045d613d0e46301b08c63.zip |
Merge pull request #915 from ooyala/master
Get rid of / improve ugly NPE when Utils.deleteRecursively() fails
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/scala/org/apache/spark/util/Utils.scala | 10 |
1 files changed, 9 insertions, 1 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 b890be2f6f..886f071503 100644 --- a/core/src/main/scala/org/apache/spark/util/Utils.scala +++ b/core/src/main/scala/org/apache/spark/util/Utils.scala @@ -457,12 +457,20 @@ private[spark] object Utils extends Logging { def newDaemonFixedThreadPool(nThreads: Int): ThreadPoolExecutor = Executors.newFixedThreadPool(nThreads, daemonThreadFactory).asInstanceOf[ThreadPoolExecutor] + private def listFilesSafely(file: File): Seq[File] = { + val files = file.listFiles() + if (files == null) { + throw new IOException("Failed to list files for dir: " + file) + } + files + } + /** * Delete a file or directory and its contents recursively. */ def deleteRecursively(file: File) { if (file.isDirectory) { - for (child <- file.listFiles()) { + for (child <- listFilesSafely(file)) { deleteRecursively(child) } } |