Github user vanzin commented on a diff in the pull request: https://github.com/apache/spark/pull/22623#discussion_r223507984 --- Diff: core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala --- @@ -70,23 +70,25 @@ trait TestPrematureExit { mainObject: CommandLineUtils = SparkSubmit) : Unit = { val printStream = new BufferPrintStream() mainObject.printStream = printStream + mainObject.exitFn = (_) => () - @volatile var exitedCleanly = false - mainObject.exitFn = (_) => exitedCleanly = true - + @volatile var exception: Exception = null val thread = new Thread { override def run() = try { mainObject.main(input) } catch { - // If exceptions occur after the "exit" has happened, fine to ignore them. - // These represent code paths not reachable during normal execution. - case e: Exception => if (!exitedCleanly) throw e + // Capture the exception to check whether the exception contains searchString or not + case e: Exception => exception = e } } thread.start() thread.join() val joined = printStream.lineBuffer.mkString("\n") - if (!joined.contains(searchString)) { + if (exception != null) { + if (!exception.getMessage.contains(searchString)) { + throw exception + } + } else if (!joined.contains(searchString)) { --- End diff -- This could be just `assert(joined.contains(blah))`. You could also move the assignment of `joined` inside the `else` here. Otherwise looks good pending tests.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org