Skip to content

Commit c6cfd33

Browse files
committed
[SPARK-6980] Changed UT ask message timeout to explicitly intercept a SparkException
1 parent 1394de6 commit c6cfd33

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

core/src/test/scala/org/apache/spark/rpc/RpcEnvSuite.scala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,14 @@ abstract class RpcEnvSuite extends SparkFunSuite with BeforeAndAfterAll {
162162
// Use anotherEnv to find out the RpcEndpointRef
163163
val rpcEndpointRef = anotherEnv.setupEndpointRef("local", env.address, "ask-timeout")
164164
try {
165-
val e = intercept[Exception] {
165+
// Any exception thrown in askWithRetry is wrapped with a SparkException and set as the cause
166+
val e = intercept[SparkException] {
166167
rpcEndpointRef.askWithRetry[String]("hello", new RpcTimeout(1 millis, shortProp))
167168
}
168-
assert(e.isInstanceOf[TimeoutException] || e.getCause.isInstanceOf[TimeoutException])
169-
e match {
170-
case te: TimeoutException =>
171-
assert(te.getMessage().contains(shortProp))
172-
case e: Exception =>
173-
assert(e.getCause().getMessage().contains(shortProp))
174-
}
169+
// The SparkException cause should be a RpcTimeoutException with message indicating the
170+
// controlling timeout property
171+
assert(e.getCause.isInstanceOf[RpcTimeoutException])
172+
assert(e.getCause().getMessage().contains(shortProp))
175173
} finally {
176174
anotherEnv.shutdown()
177175
anotherEnv.awaitTermination()

0 commit comments

Comments
 (0)