Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/9367#discussion_r44447058
--- Diff:
core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala ---
@@ -366,6 +367,72 @@ class SparkSubmitSuite
}
}
+ // SPARK-11195
+ test("classes are correctly loaded when tasks fail") {
+ // Compile a simple jar that throws a user defined exception on the
driver
+ val tempDir = Utils.createTempDir()
+ val srcDir = new File(tempDir, "repro/")
+ srcDir.mkdirs()
+ // scalastyle:off line.size.limit
+ val mainSource = new JavaSourceFromString(new File(srcDir,
"MyJob").getAbsolutePath,
+ """package repro;
+ |
+ |import java.util.*;
+ |import java.util.regex.*;
+ |import org.apache.spark.*;
+ |import org.apache.spark.api.java.*;
+ |import org.apache.spark.api.java.function.*;
+ |
+ |public class MyJob {
+ | public static class MyException extends Exception {
+ | }
+ |
+ | public static void main(String[] args) {
+ | SparkConf conf = new SparkConf();
+ | JavaSparkContext sc = new JavaSparkContext(conf);
+ |
+ | JavaRDD rdd = sc.parallelize(Arrays.asList(new Integer[]{1}),
1).map(new Function<Integer, Boolean>() {
+ | public Boolean call(Integer x) throws MyException {
+ | throw new MyException();
+ | }
+ | });
+ |
+ | try {
+ | rdd.collect();
+ |
+ | assert(false); // should be unreachable
+ | } catch (Exception e) {
+ | // the driver should not have any problems resolving the
exception class and determining
+ | // why the task failed.
+ |
+ | Pattern unknownFailure = Pattern.compile(".*Lost task.*:
UnknownReason.*", Pattern.DOTALL);
+ | Pattern expectedFailure = Pattern.compile(".*Lost task.*:
repro.MyJob\\$MyException.*", Pattern.DOTALL);
+ |
+ | assert(!unknownFailure.matcher(e.getMessage()).matches());
+ | assert(expectedFailure.matcher(e.getMessage()).matches());
+ | }
+ | }
+ |}
+ """.stripMargin)
+ // scalastyle:on line.size.limit
+ val sparkJar =
"../assembly/target/scala-2.10/spark-assembly-1.5.1-hadoop2.2.0.jar"
--- End diff --
We should go with the simplest option that reproduces the issue. In other
`SparkSubmitSuite` tests we used (2) but only out of necessity, where we just
prepackage a jar and put it in the test resources dir. This makes it a little
hard to maintain, e.g. it doesn't work with scala-2.11.
In this case, maybe (3) is the simplest and most maintainable. It's
unlikely that we'll ever have to modify `MyException`, but the reproduction
code itself should be kept flexible. Could you give it a try?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]