Skip to content

Commit f661ce7

Browse files
committed
Remove thread local; add comment instead
1 parent 64f8398 commit f661ce7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

core/src/main/scala/org/apache/spark/executor/CoarseGrainedExecutorBackend.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ private[spark] class CoarseGrainedExecutorBackend(
4848
var executor: Executor = null
4949
@volatile var driver: Option[RpcEndpointRef] = None
5050

51-
// This is a thread-local in case we ever decide to change this to a non-thread-safe RpcEndpoint
52-
private[this] val ser: ThreadLocal[SerializerInstance] = new ThreadLocal[SerializerInstance] {
53-
override def initialValue: SerializerInstance = env.closureSerializer.newInstance()
54-
}
51+
// If this CoarseGrainedExecutorBackend is changed to support multiple threads, then this may need
52+
// to be changed so that we don't share the serializer instance across threads
53+
private[this] val ser: SerializerInstance = env.closureSerializer.newInstance()
5554

5655
override def onStart() {
5756
import scala.concurrent.ExecutionContext.Implicits.global
@@ -89,7 +88,7 @@ private[spark] class CoarseGrainedExecutorBackend(
8988
logError("Received LaunchTask command but executor was null")
9089
System.exit(1)
9190
} else {
92-
val taskDesc = ser.get().deserialize[TaskDescription](data.value)
91+
val taskDesc = ser.deserialize[TaskDescription](data.value)
9392
logInfo("Got assigned task " + taskDesc.taskId)
9493
executor.launchTask(this, taskId = taskDesc.taskId, attemptNumber = taskDesc.attemptNumber,
9594
taskDesc.name, taskDesc.serializedTask)

0 commit comments

Comments
 (0)