File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
core/src/main/scala/org/apache/spark Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ class SparkEnv (
91
91
// actorSystem.awaitTermination()
92
92
93
93
// Note that blockTransferService is stopped by BlockManager since it is started by it.
94
+
95
+ // clear all the references in ThreadLocal object
96
+ SparkEnv .reset()
94
97
}
95
98
96
99
private [spark]
@@ -119,7 +122,7 @@ class SparkEnv (
119
122
}
120
123
121
124
object SparkEnv extends Logging {
122
- private val env = new ThreadLocal [SparkEnv ]
125
+ @ volatile private var env = new ThreadLocal [SparkEnv ]
123
126
@ volatile private var lastSetSparkEnv : SparkEnv = _
124
127
125
128
private [spark] val driverActorSystemName = " sparkDriver"
@@ -130,6 +133,12 @@ object SparkEnv extends Logging {
130
133
env.set(e)
131
134
}
132
135
136
+ // clear all the threadlocal references
137
+ private [spark] def reset (): Unit = {
138
+ env = new ThreadLocal [SparkEnv ]
139
+ lastSetSparkEnv = null
140
+ }
141
+
133
142
/**
134
143
* Returns the ThreadLocal SparkEnv, if non-null. Else returns the SparkEnv
135
144
* previously set in any thread.
You can’t perform that action at this time.
0 commit comments