Repository: spark Updated Branches: refs/heads/branch-1.0 7305278a0 -> afcb9aefc
SPARK-1710: spark-submit should print better errors than "InvocationTargetException" Catching the InvocationTargetException, printing getTargetException. Author: Sandeep <[email protected]> Closes #630 from techaddict/SPARK-1710 and squashes the following commits: 834d79b [Sandeep] changes from srowen suggestions 109d604 [Sandeep] SPARK-1710: spark-submit should print better errors than "InvocationTargetException" (cherry picked from commit b48a55ae9ff2976c5fe6f5776a6d4659e828ee24) Signed-off-by: Patrick Wendell <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/afcb9aef Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/afcb9aef Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/afcb9aef Branch: refs/heads/branch-1.0 Commit: afcb9aefc22a6e29821c5c88682ac0515fa31f1d Parents: 7305278 Author: Sandeep <[email protected]> Authored: Sun May 4 20:51:53 2014 -0700 Committer: Patrick Wendell <[email protected]> Committed: Sun May 4 20:52:01 2014 -0700 ---------------------------------------------------------------------- .../scala/org/apache/spark/deploy/SparkSubmit.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/afcb9aef/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala ---------------------------------------------------------------------- diff --git a/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala b/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala index d131f18..fb30e8a 100644 --- a/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala +++ b/core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala @@ -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} @@ -137,7 +138,7 @@ object SparkSubmit { throw new Exception(msg) } } - + // Special flag to avoid deprecation warnings at the client sysProps("SPARK_SUBMIT") = "true" @@ -253,7 +254,14 @@ 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 => e.getCause match { + case cause: Throwable => throw cause + case null => throw e + } + } } private def addJarToClasspath(localJar: String, loader: ExecutorURLClassLoader) {
