diff --git a/core/src/test/scala/org/apache/spark/SparkContextSuite.scala b/core/src/test/scala/org/apache/spark/SparkContextSuite.scala index 04a00425f5eb3..5c57940fa5f77 100644 --- a/core/src/test/scala/org/apache/spark/SparkContextSuite.scala +++ b/core/src/test/scala/org/apache/spark/SparkContextSuite.scala @@ -275,16 +275,14 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext { } test("calling multiple sc.stop() must not throw any exception") { - try { + noException should be thrownBy { sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local")) val cnt = sc.parallelize(1 to 4).count() sc.cancelAllJobs() sc.stop() // call stop second time sc.stop() - } catch { - case e: Exception => - fail("calling multiple sc.stop() must not have thrown any exception", e); } } + }