Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
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
2 changes: 0 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 @@ -927,8 +927,6 @@ object SparkSubmit extends CommandLineUtils with Logging {
} catch {
case e: SparkUserAppException =>
exitFn(e.exitCode)
case e: SparkException =>
printErrorAndExit(e.getMessage())
}
}

Expand Down
17 changes: 11 additions & 6 deletions core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,25 @@ trait TestPrematureExit {
@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)) {
fail(s"Search string '$searchString' not found in $joined")
if (exitedCleanly) {
val joined = printStream.lineBuffer.mkString("\n")
assert(joined.contains(searchString), s"Search string '$searchString' not found in $joined")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The message is redundant, assert already gives you a nice message, e.g.

[info]   "foo" did not contain "bar" (blah.scala)

} else {
assert(exception != null)
if (!exception.getMessage.contains(searchString)) {
throw exception
}
}
}
}
Expand Down