Skip to content

Commit 7a8ca43

Browse files
author
Patrick Woody
committed
Initialize properly
1 parent 04cc399 commit 7a8ca43

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingSymmetricHashJoinHelperSuite.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ class StreamingSymmetricHashJoinHelperSuite extends StreamTest {
3535
val rightColC = new Column(rightAttributeC)
3636
val rightColD = new Column(rightAttributeD)
3737

38-
val left = new LocalTableScanExec(Seq(leftAttributeA, leftAttributeB), Seq())
39-
val right = new LocalTableScanExec(Seq(rightAttributeC, rightAttributeD), Seq())
38+
var left: LocalTableScanExec = _
39+
var right: LocalTableScanExec = _
40+
41+
protected override def beforeAll(): Unit = {
42+
super.beforeAll()
43+
left = new LocalTableScanExec(Seq(leftAttributeA, leftAttributeB), Seq())
44+
right = new LocalTableScanExec(Seq(rightAttributeC, rightAttributeD), Seq())
45+
}
4046

4147
test("empty") {
4248
val split = JoinConditionSplitPredicates(None, left, right)
@@ -123,4 +129,5 @@ class StreamingSymmetricHashJoinHelperSuite extends StreamTest {
123129
assert(split.bothSides.contains((leftColA === rightColC && randCol > lit(0)).expr))
124130
assert(split.full.contains(predicate))
125131
}
132+
126133
}

sql/core/src/test/scala/org/apache/spark/sql/test/SharedSparkSession.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ trait SharedSparkSession
8383
* Make sure the [[TestSparkSession]] is initialized before any tests are run.
8484
*/
8585
protected override def beforeAll(): Unit = {
86-
initializeSession()
86+
this.synchronized {
87+
initializeSession()
88+
}
8789

8890
// Ensure we have initialized the context before calling parent code
8991
super.beforeAll()
@@ -97,12 +99,14 @@ trait SharedSparkSession
9799
super.afterAll()
98100
} finally {
99101
try {
100-
if (_spark != null) {
101-
try {
102-
_spark.sessionState.catalog.reset()
103-
} finally {
104-
_spark.stop()
105-
_spark = null
102+
this.synchronized {
103+
if (_spark != null) {
104+
try {
105+
_spark.sessionState.catalog.reset()
106+
} finally {
107+
_spark.stop()
108+
_spark = null
109+
}
106110
}
107111
}
108112
} finally {

0 commit comments

Comments
 (0)