Skip to content

Commit

Permalink
clear reference of SparkEnv after stop
Browse files Browse the repository at this point in the history
  • Loading branch information
davies committed Oct 2, 2014
1 parent bbdf1de commit 4d0ea8b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/src/main/scala/org/apache/spark/SparkEnv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class SparkEnv (
// actorSystem.awaitTermination()

// Note that blockTransferService is stopped by BlockManager since it is started by it.

// clear all the references in ThreadLocal object
SparkEnv.reset()
}

private[spark]
Expand Down Expand Up @@ -119,7 +122,7 @@ class SparkEnv (
}

object SparkEnv extends Logging {
private val env = new ThreadLocal[SparkEnv]
@volatile private var env = new ThreadLocal[SparkEnv]
@volatile private var lastSetSparkEnv : SparkEnv = _

private[spark] val driverActorSystemName = "sparkDriver"
Expand All @@ -130,6 +133,12 @@ object SparkEnv extends Logging {
env.set(e)
}

// clear all the threadlocal references
private[spark] def reset(): Unit = {
env = new ThreadLocal[SparkEnv]
lastSetSparkEnv = null
}

/**
* Returns the ThreadLocal SparkEnv, if non-null. Else returns the SparkEnv
* previously set in any thread.
Expand Down

0 comments on commit 4d0ea8b

Please sign in to comment.