diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala index 58bb97a391293..9533df189f8f8 100644 --- a/core/src/main/scala/org/apache/spark/SparkContext.scala +++ b/core/src/main/scala/org/apache/spark/SparkContext.scala @@ -349,17 +349,14 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli // Thread Local variable that can be used by users to pass information down the stack private val localProperties = new InheritableThreadLocal[Properties] { override protected def childValue(parent: Properties): Properties = { - if (nonInheritedLocalProperties.nonEmpty) { - // If there are properties that should not be inherited, filter them out - val p = new Properties - val filtered = parent.asScala.filter { case (k, _) => - !nonInheritedLocalProperties.contains(k) - } - p.putAll(filtered.asJava) - p - } else { - new Properties(parent) + // Note: make a clone such that changes in the parent properties aren't reflected in + // the those of the children threads, which has confusing semantics (SPARK-10564). + val p = new Properties + val filtered = parent.asScala.filter { case (k, _) => + !nonInheritedLocalProperties.contains(k) } + p.putAll(filtered.asJava) + p } override protected def initialValue(): Properties = new Properties() }