Skip to content

Commit be42f35

Browse files
committed
Handle case where SPARK_HOME is not set
1 parent c2a2909 commit be42f35

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ private[spark] class SparkSubmitArguments(args: Array[String]) {
5555
if (primaryResource == null) SparkSubmit.printErrorAndExit("Must specify a primary resource")
5656
if (mainClass == null) SparkSubmit.printErrorAndExit("Must specify a main class with --class")
5757
if (propertiesFile == null) {
58-
val sparkHome = sys.env("SPARK_HOME") // defined via `spark-class`
59-
val sep = File.separator
60-
val defaultPath = s"${sparkHome}${sep}conf${sep}spark-defaults.properties"
61-
val file = new File(defaultPath)
62-
if (file.exists()) {
63-
propertiesFile = file.getAbsolutePath
64-
}
58+
sys.env.get("SPARK_HOME").foreach { sparkHome =>
59+
val sep = File.separator
60+
val defaultPath = s"${sparkHome}${sep}conf${sep}spark-defaults.properties"
61+
val file = new File(defaultPath)
62+
if (file.exists()) {
63+
propertiesFile = file.getAbsolutePath
64+
}
65+
}
6566
}
6667

6768
override def toString = {

0 commit comments

Comments
 (0)