Github user kunalkhamar commented on a diff in the pull request:

    https://github.com/apache/spark/pull/16826#discussion_r104780858
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/SessionStateSuite.scala ---
    @@ -20,86 +20,105 @@ package org.apache.spark.sql
     import org.scalatest.BeforeAndAfterAll
     import org.scalatest.BeforeAndAfterEach
     
    -import org.apache.spark.SparkContext
     import org.apache.spark.SparkFunSuite
     import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
     import org.apache.spark.sql.catalyst.rules.Rule
     
     class SessionStateSuite extends SparkFunSuite
         with BeforeAndAfterEach with BeforeAndAfterAll {
     
    +  /**
    +   * A shared SparkSession for all tests in this suite. Make sure you 
reset any changes to this
    +   * session as this is a singleton HiveSparkSession in 
HiveSessionStateSuite and it's shared
    +   * with all Hive test suites.
    +   */
       protected var activeSession: SparkSession = _
    -  protected var sparkContext: SparkContext = null
     
       override def beforeAll(): Unit = {
    -    sparkContext = 
SparkSession.builder().master("local").getOrCreate().sparkContext
    +    activeSession = SparkSession.builder().master("local").getOrCreate()
       }
     
    -  protected def createSession(): Unit = {
    -    activeSession =
    -      
SparkSession.builder().master("local").sparkContext(sparkContext).getOrCreate()
    -  }
    -
    -  override def beforeEach(): Unit = {
    -    createSession()
    +  override def afterAll(): Unit = {
    +    if (activeSession != null) {
    +      activeSession.stop()
    +      activeSession = null
    +    }
    +    super.afterAll()
       }
     
       test("fork new session and inherit RuntimeConfig options") {
         val key = "spark-config-clone"
         activeSession.conf.set(key, "active")
    --- End diff --
    
    Shoud this be inside try {} ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to