dongjoon-hyun commented on a change in pull request #24807: [SPARK-27958][SQL] 
Stopping a SparkSession should not always stop Spark Context
URL: https://github.com/apache/spark/pull/24807#discussion_r291823345
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
 ##########
 @@ -1004,12 +1024,17 @@ object SparkSession extends Logging {
   }
 
   /**
-   * Clears the default SparkSession that is returned by the builder.
-   *
+   * Clears the default SparkSession that is returned by the builder
+   * if it is not null.
    * @since 2.0.0
    */
   def clearDefaultSession(): Unit = {
-    defaultSession.set(null)
+    if (getDefaultSession.isDefined) {
+      defaultSession.set(null)
+    } else {
+      logWarning("Calling clearDefaultSession() on a SparkSession " +
+        "without an default session is a noop.")
+    }
 
 Review comment:
   For me, the existing behavior is a quiet no-op and looks better.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to