Skip to content

Commit

Permalink
Try with if-else
Browse files Browse the repository at this point in the history
  • Loading branch information
HyukjinKwon committed Apr 27, 2017
1 parent 0f55c49 commit b5c9839
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,13 @@ private[spark] object Utils extends Logging {
* always return a single directory.
*/
def getLocalDir(conf: SparkConf): String = {
getOrCreateLocalRootDirs(conf).headOption.getOrElse {
val dirPaths = getConfiguredLocalDirs(conf)
throw new IOException(s"Failed to get a temp directory under [${dirPaths.mkString(",")}].")
val localRootDirs = getOrCreateLocalRootDirs(conf)
if (localRootDirs.nonEmpty) {
localRootDirs(0)
} else {
val configuredLocalDirs = getConfiguredLocalDirs(conf)
throw new IOException(
s"Failed to get a temp directory under [${configuredLocalDirs.mkString(",")}].")
}
}

Expand Down

0 comments on commit b5c9839

Please sign in to comment.