[SPARK-20886][CORE] HadoopMapReduceCommitProtocol to handle FileOutputCommitter.getWorkPath==null

## What changes were proposed in this pull request?

Handles the situation where a `FileOutputCommitter.getWorkPath()` returns `null` by downgrading to the supplied `path` argument.

The existing code does an  `Option(workPath.toString).getOrElse(path)`, which triggers an NPE in the `toString()` operation if the workPath == null. The code apparently was meant to handle this (hence the getOrElse() clause, but as the NPE has already occurred at that point the else-clause never gets invoked.

## How was this patch tested?

Manually, with some later code review.

Author: Steve Loughran <stevel@hortonworks.com>

Closes #18111 from steveloughran/cloud/SPARK-20886-committer-NPE.
This commit is contained in:
Steve Loughran 2017-08-30 13:03:30 +09:00 committed by hyukjinkwon
parent 3d0e174244
commit e47f48c737

View file

@ -73,7 +73,8 @@ class HadoopMapReduceCommitProtocol(jobId: String, path: String)
val stagingDir: String = committer match {
// For FileOutputCommitter it has its own staging path called "work path".
case f: FileOutputCommitter => Option(f.getWorkPath.toString).getOrElse(path)
case f: FileOutputCommitter =>
Option(f.getWorkPath).map(_.toString).getOrElse(path)
case _ => path
}