Skip to content
Snippets Groups Projects
Commit c81377b9 authored by Matei Zaharia's avatar Matei Zaharia
Browse files

Merge pull request #915 from ooyala/master

Get rid of / improve ugly NPE when Utils.deleteRecursively() fails
parents 61d2a010 fdb8b0ee
No related branches found
No related tags found
No related merge requests found
......@@ -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)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment