Ngone51 commented on a change in pull request #31053:
URL: https://github.com/apache/spark/pull/31053#discussion_r557261980
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/SparkSessionBuilderSuite.scala
##########
@@ -196,6 +198,71 @@ class SparkSessionBuilderSuite extends SparkFunSuite with
BeforeAndAfterEach {
assert(postFirstCreation == postSecondCreation)
}
+ test("SPARK-32165: SparkContext only register one SQLAppStatusListener") {
+ val conf = new SparkConf()
+ .setMaster("local")
+ .setAppName("test-register-one-SQLAppStatusListener")
+ val context = new SparkContext(conf)
+ SparkSession
+ .builder()
+ .sparkContext(context)
+ .master("local")
+ .getOrCreate()
+ // Touches the sessionState so it initiate SQLAppStatusListener and
ExecutionListenerBus
+ .sessionState
+
+ assert(countListener("SQLAppStatusListener", context) === 1)
+ assert(countListener("ExecutionListenerBus", context) === 1)
+ val postFirstCreation = context.listenerBus.listeners.size()
+ SparkSession.clearActiveSession()
+ SparkSession.clearDefaultSession()
+
+ SparkSession
+ .builder()
+ .sparkContext(context)
+ .master("local")
+ .getOrCreate()
+ .sessionState
+ assert(countListener("SQLAppStatusListener", context) === 1)
+ assert(countListener("ExecutionListenerBus", context) === 2)
+ val postSecondCreation = context.listenerBus.listeners.size()
+ SparkSession.clearActiveSession()
+ SparkSession.clearDefaultSession()
+ // Minus 1 because the listener `ExecutionListenerBus` is created per
SparkSession
+ assert(postFirstCreation == postSecondCreation - 1)
Review comment:
No. Here we want to ensure other potential listeners won't leak across
SparkSessions.
----------------------------------------------------------------
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]