You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/07/02 12:50:59 UTC

[GitHub] [spark] ulysses-you commented on a change in pull request #28868: [SPARK-32029][SQL] Check spark context is stoped when get active session

ulysses-you commented on a change in pull request #28868:
URL: https://github.com/apache/spark/pull/28868#discussion_r448977301



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SparkSessionBuilderSuite.scala
##########
@@ -257,4 +257,25 @@ class SparkSessionBuilderSuite extends SparkFunSuite with BeforeAndAfterEach {
       context.stop()
     }
   }
+
+  test("SPARK-32029: check active session if spark context is stop") {
+    val conf = new SparkConf()
+      .setMaster("local")
+      .setAppName("test-SPARK-32029")
+    val context = new SparkContext(conf)
+    val session = SparkSession
+      .builder()
+      .sparkContext(context)
+      .getOrCreate()
+
+    context.stop()
+    val msg = intercept[IllegalStateException] {
+      session.withActive()
+    }.getMessage
+    assert(msg.contains("Cannot call methods on a stopped SparkContext."))
+    val msg2 = intercept[IllegalStateException] {
+      SparkSession.getActiveSession

Review comment:
       Yes, now we only clear default session, active session is still alive.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org