File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
core/src/test/scala/org/apache/spark/deploy Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -74,26 +74,27 @@ trait TestPrematureExit {
7474 @ volatile var exitedCleanly = false
7575 mainObject.exitFn = (_) => exitedCleanly = true
7676
77- var message : String = null
77+ var exception : Exception = null
7878 val thread = new Thread {
7979 override def run () = try {
8080 mainObject.main(input)
8181 } catch {
8282 // If exceptions occur after the "exit" has happened, fine to ignore them.
8383 // These represent code paths not reachable during normal execution.
84- case e : Exception =>
85- message = e.getMessage
86- if (! (exitedCleanly || message.contains(searchString))) {
87- throw e
88- }
84+ case e : Exception => exception = e
8985 }
9086 }
9187 thread.start()
9288 thread.join()
9389 val joined = printStream.lineBuffer.mkString(" \n " )
94- if (! (joined.contains(searchString) ||
95- (message != null && message.contains(searchString)))) {
96- fail(s " Search string ' $searchString' not found in $joined or in $message" )
90+ val searchStrContainsInEx = exception != null && exception.getMessage.contains(searchString)
91+ if (! searchStrContainsInEx){
92+ if (! exitedCleanly){
93+ // throw the exception when the exception message doesn't contain searchString and not exitedCleanly.
94+ throw exception
95+ } else if (! joined.contains(searchString)){
96+ fail(s " Search string ' $searchString' not found in $joined" )
97+ }
9798 }
9899 }
99100}
You can’t perform that action at this time.
0 commit comments