Skip to content

Commit

Permalink
Merge pull request #940 from ankurdave/clear-port-properties-after-tests
Browse files Browse the repository at this point in the history
After unit tests, clear port properties unconditionally
  • Loading branch information
rxin committed Sep 22, 2013
2 parents cd7222c + 026dba6 commit 7bb12a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 5 additions & 5 deletions core/src/test/scala/org/apache/spark/LocalSparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ trait LocalSparkContext extends BeforeAndAfterEach with BeforeAndAfterAll { self
}

def resetSparkContext() = {
if (sc != null) {
LocalSparkContext.stop(sc)
sc = null
}
LocalSparkContext.stop(sc)
sc = null
}

}

object LocalSparkContext {
def stop(sc: SparkContext) {
sc.stop()
if (sc != null) {
sc.stop()
}
// To avoid Akka rebinding to the same port, since it doesn't unbind immediately on shutdown
System.clearProperty("spark.driver.port")
System.clearProperty("spark.hostPort")
Expand Down
6 changes: 2 additions & 4 deletions core/src/test/scala/org/apache/spark/SharedSparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ trait SharedSparkContext extends BeforeAndAfterAll { self: Suite =>
}

override def afterAll() {
if (_sc != null) {
LocalSparkContext.stop(_sc)
_sc = null
}
LocalSparkContext.stop(_sc)
_sc = null
super.afterAll()
}
}

0 comments on commit 7bb12a2

Please sign in to comment.