File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
main/scala/org/apache/spark
test/scala/org/apache/spark Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ class SparkEnv (
9393
9494 private [spark] def stop () {
9595
96- if (! isStopped) {
96+ if (! isStopped) {
9797 isStopped = true
9898 try {
9999 pythonWorkers.foreach { case (key, worker) => worker.stop()}
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import org.apache.spark.util.Utils
3030
3131import scala .concurrent .Await
3232import scala .concurrent .duration .Duration
33+ import scala .util .control .NonFatal
3334
3435class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
3536
@@ -272,4 +273,24 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
272273 sc.stop()
273274 }
274275 }
276+
277+ test(" calling multiple sc.stop() must not throw uncaught exception(50) from sparkenv" ) {
278+ var threwNoOrOnlyExceptedException = true
279+ try {
280+ sc = new SparkContext (new SparkConf ().setAppName(" test" ).setMaster(" local" ))
281+ val cnt = sc.parallelize(1 to 4 ).count()
282+ sc.cancelAllJobs()
283+ sc.stop()
284+ // call stop second time
285+ sc.stop()
286+ } catch {
287+ case e : ServerStateException =>
288+ // assert(!e.getMessage.contains("Server is already stopped"))
289+ threwNoOrOnlyExceptedException = false
290+ case NonFatal (e) =>
291+ threwNoOrOnlyExceptedException = true
292+ } finally {
293+ assert(threwNoOrOnlyExceptedException == true )
294+ }
295+ }
275296}
You can’t perform that action at this time.
0 commit comments