Skip to content

Commit 5297f79

Browse files
author
Andrew Or
committed
Always clone parent properties
... to make the behavior more consistent in SQL vs non-SQL cases.
1 parent bbda199 commit 5297f79

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -349,17 +349,14 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
349349
// Thread Local variable that can be used by users to pass information down the stack
350350
private val localProperties = new InheritableThreadLocal[Properties] {
351351
override protected def childValue(parent: Properties): Properties = {
352-
if (nonInheritedLocalProperties.nonEmpty) {
353-
// If there are properties that should not be inherited, filter them out
354-
val p = new Properties
355-
val filtered = parent.asScala.filter { case (k, _) =>
356-
!nonInheritedLocalProperties.contains(k)
357-
}
358-
p.putAll(filtered.asJava)
359-
p
360-
} else {
361-
new Properties(parent)
352+
// Note: make a clone such that changes in the parent properties aren't reflected in
353+
// the those of the children threads, which has confusing semantics (SPARK-10564).
354+
val p = new Properties
355+
val filtered = parent.asScala.filter { case (k, _) =>
356+
!nonInheritedLocalProperties.contains(k)
362357
}
358+
p.putAll(filtered.asJava)
359+
p
363360
}
364361
override protected def initialValue(): Properties = new Properties()
365362
}

0 commit comments

Comments
 (0)