Skip to content

Commit 7bb12a2

Browse files
committed
Merge pull request apache#940 from ankurdave/clear-port-properties-after-tests
After unit tests, clear port properties unconditionally
2 parents cd7222c + 026dba6 commit 7bb12a2

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

core/src/test/scala/org/apache/spark/LocalSparkContext.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ trait LocalSparkContext extends BeforeAndAfterEach with BeforeAndAfterAll { self
4040
}
4141

4242
def resetSparkContext() = {
43-
if (sc != null) {
44-
LocalSparkContext.stop(sc)
45-
sc = null
46-
}
43+
LocalSparkContext.stop(sc)
44+
sc = null
4745
}
4846

4947
}
5048

5149
object LocalSparkContext {
5250
def stop(sc: SparkContext) {
53-
sc.stop()
51+
if (sc != null) {
52+
sc.stop()
53+
}
5454
// To avoid Akka rebinding to the same port, since it doesn't unbind immediately on shutdown
5555
System.clearProperty("spark.driver.port")
5656
System.clearProperty("spark.hostPort")

core/src/test/scala/org/apache/spark/SharedSparkContext.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ trait SharedSparkContext extends BeforeAndAfterAll { self: Suite =>
3333
}
3434

3535
override def afterAll() {
36-
if (_sc != null) {
37-
LocalSparkContext.stop(_sc)
38-
_sc = null
39-
}
36+
LocalSparkContext.stop(_sc)
37+
_sc = null
4038
super.afterAll()
4139
}
4240
}

0 commit comments

Comments
 (0)