After unit tests, clear port properties unconditionally
In MapOutputTrackerSuite, the "remote fetch" test sets spark.driver.port and spark.hostPort, assuming that they will be cleared by LocalSparkContext. However, the test never sets sc, so it remains null, causing LocalSparkContext to skip clearing these properties. Subsequent tests therefore fail with java.net.BindException: "Address already in use". This commit makes LocalSparkContext clear the properties even if sc is null.
This commit is contained in:
parent
cd7222c3dd
commit
026dba6aba
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue