Skip to content
Snippets Groups Projects
Commit fae88af1 authored by Terence Yim's avatar Terence Yim Committed by Sean Owen
Browse files

[SPARK-13441][YARN] Fix NPE in yarn Client.createConfArchive method

## What changes were proposed in this pull request?

Instead of using result of File.listFiles() directly, which may throw NPE, check for null first. If it is null, log a warning instead

## How was the this patch tested?

Ran the ./dev/run-tests locally
Tested manually on a cluster

Author: Terence Yim <terence@cask.co>

Closes #11337 from chtyim/fixes/SPARK-13441-null-check.
parent 6f8e835c
No related branches found
No related tags found
No related merge requests found
......@@ -537,9 +537,14 @@ private[spark] class Client(
sys.env.get(envKey).foreach { path =>
val dir = new File(path)
if (dir.isDirectory()) {
dir.listFiles().foreach { file =>
if (file.isFile && !hadoopConfFiles.contains(file.getName())) {
hadoopConfFiles(file.getName()) = file
val files = dir.listFiles()
if (files == null) {
logWarning("Failed to list files under directory " + dir)
} else {
files.foreach { file =>
if (file.isFile && !hadoopConfFiles.contains(file.getName())) {
hadoopConfFiles(file.getName()) = file
}
}
}
}
......
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