Skip to content

Commit 1aff39c

Browse files
committed
Fix for SparkContext stop behavior
1 parent 12f66b5 commit 1aff39c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

core/src/test/scala/org/apache/spark/SparkContextSuite.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import org.apache.spark.util.Utils
3030

3131
import scala.concurrent.Await
3232
import scala.concurrent.duration.Duration
33+
import org.scalatest.Matchers._
3334

3435
class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
3536

@@ -274,16 +275,13 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
274275
}
275276

276277
test("calling multiple sc.stop() must not throw any exception") {
277-
try {
278+
noException should be thrownBy {
278279
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local"))
279280
val cnt = sc.parallelize(1 to 4).count()
280281
sc.cancelAllJobs()
281282
sc.stop()
282283
// call stop second time
283284
sc.stop()
284-
} catch {
285-
case e: Exception =>
286-
fail("calling multiple sc.stop() must not throw any exception", e);
287285
}
288286
}
289287
}

0 commit comments

Comments
 (0)