stczwd commented on a change in pull request #28128:
URL: https://github.com/apache/spark/pull/28128#discussion_r427889488
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
##########
@@ -940,20 +939,19 @@ object SparkSession extends Logging {
options.foreach { case (k, v) => session.initialSessionOptions.put(k,
v) }
setDefaultSession(session)
setActiveSession(session)
-
- // Register a successfully instantiated context to the singleton. This
should be at the
- // end of the class definition so that the singleton is updated only
if there is no
- // exception in the construction of the instance.
- sparkContext.addSparkListener(new SparkListener {
- override def onApplicationEnd(applicationEnd:
SparkListenerApplicationEnd): Unit = {
- defaultSession.set(null)
- }
- })
+ registerSessionListenerOnContext(sparkContext)
}
return session
}
+ private def registerSessionListenerOnContext(sparkContext: SparkContext):
Unit = {
Review comment:
maybe move _sessionListener definition inside of
sessionListenerRegistered? _sessionListener seems useless outside of the
sessionListenerRegistered.
Also, maybe add some tests?
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]