Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ object CommandUtils extends Logging {
def buildJavaOpts(command: Command, memory: Int, sparkHome: String): Seq[String] = {
val memoryOpts = Seq(s"-Xms${memory}M", s"-Xmx${memory}M")
// Note, this will coalesce multiple options into a single command component
val extraOpts = command.extraJavaOptions.toSeq
val extraOpts = command.extraJavaOptions.map(Utils.splitCommandString).getOrElse(Seq())

val libraryOpts =
if (command.libraryPathEntries.size > 0) {
val joined = command.libraryPathEntries.mkString(File.pathSeparator)
Expand All @@ -62,10 +63,10 @@ object CommandUtils extends Logging {
val classPath = Utils.executeAndGetOutput(
Seq(sparkHome + "/bin/compute-classpath" + ext),
extraEnvironment=command.environment)
val userClassPath = command.classPathEntries.mkString(File.pathSeparator)
val classPathWithUser = classPath + File.pathSeparator + userClassPath
val userClassPath = command.classPathEntries ++ Seq(classPath)

Seq("-cp", classPathWithUser) ++ libraryOpts ++ extraOpts ++ memoryOpts
Seq("-cp", userClassPath.filterNot(_.isEmpty).mkString(File.pathSeparator)) ++
libraryOpts ++ extraOpts ++ memoryOpts
}

/** Spawn a thread that will redirect a given stream to a file */
Expand Down