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 (
93
93
94
94
private [spark] def stop () {
95
95
96
- if (! isStopped) {
96
+ if (! isStopped) {
97
97
isStopped = true
98
98
try {
99
99
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
30
30
31
31
import scala .concurrent .Await
32
32
import scala .concurrent .duration .Duration
33
+ import scala .util .control .NonFatal
33
34
34
35
class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
35
36
@@ -272,4 +273,24 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
272
273
sc.stop()
273
274
}
274
275
}
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
+ }
275
296
}
You can’t perform that action at this time.
0 commit comments