Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.spark.deploy

import java.io.{File, PrintStream}
import java.lang.reflect.InvocationTargetException
import java.net.{URI, URL}

import scala.collection.mutable.{ArrayBuffer, HashMap, Map}
Expand Down Expand Up @@ -137,7 +138,7 @@ object SparkSubmit {
throw new Exception(msg)
}
}

// Special flag to avoid deprecation warnings at the client
sysProps("SPARK_SUBMIT") = "true"

Expand Down Expand Up @@ -253,7 +254,12 @@ object SparkSubmit {

val mainClass = Class.forName(childMainClass, true, loader)
val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)
mainMethod.invoke(null, childArgs.toArray)
try {
mainMethod.invoke(null, childArgs.toArray)
} catch {
case e: InvocationTargetException =>
println("Exception in Invoked Method" + e.getTargetException)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is going to change behavior in two ways though. This will not print any stack trace, and the exception will not propagated up to main() where it will terminate the program with a non-zero status. Both of those seems like good normal things. Instead, just throw e.getTargetException? (I suppose it would be even better to handle the case of a null target, but that is not supposed to happen in normal use.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas on how to handle null ? I'm thinking of comparing to null.asInstanceOf[Throwable] What do you think ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

  case e: InvocationTargetException => e.getCause match {
    case cause: Throwable => throw cause
    case null => throw e
  }

(getCause is a little more standard)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better 👍

}
}

private def addJarToClasspath(localJar: String, loader: ExecutorURLClassLoader) {
Expand Down