File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
main/scala/org/apache/spark
test/scala/org/apache/spark Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -49,8 +49,9 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
4949
5050 if (loadDefaults) {
5151 // Load any spark.* system properties
52- for ((k, v) <- System .getProperties.asScala if k.startsWith(" spark." )) {
53- settings(k) = v
52+ val propNames = System .getProperties.stringPropertyNames().asScala
53+ for (k <- propNames if k.startsWith(" spark." )) {
54+ settings(k) = System .getProperty(k)
5455 }
5556 }
5657
Original file line number Diff line number Diff line change 1717
1818package org .apache .spark
1919
20+ import java .util .concurrent .{TimeUnit , Executors }
21+
22+ import scala .util .{Try , Random }
23+
2024import org .scalatest .FunSuite
2125
2226import org .apache .spark .util .ResetSystemProperties
@@ -121,4 +125,25 @@ class SparkConfSuite extends FunSuite with LocalSparkContext with ResetSystemPro
121125 assert(conf.get(" spark.test.a.b" ) === " A.B" )
122126 assert(conf.get(" spark.test.a.b.c" ) === " a.b.c" )
123127 }
128+
129+ test(" Thread safeness - SPARK-5425" ) {
130+ import scala .collection .JavaConversions ._
131+ val executor = Executors .newSingleThreadScheduledExecutor()
132+ val sf = executor.scheduleAtFixedRate(new Runnable {
133+ override def run (): Unit =
134+ System .setProperty(" spark.5425." + Random .nextInt(), Random .nextInt().toString)
135+ }, 0 , 1 , TimeUnit .MILLISECONDS )
136+
137+ try {
138+ val t0 = System .currentTimeMillis()
139+ while ((System .currentTimeMillis() - t0) < 1000 ) {
140+ val conf = Try (new SparkConf (loadDefaults = true ))
141+ assert(conf.isSuccess === true )
142+ }
143+ } finally {
144+ executor.shutdownNow()
145+ for (key <- System .getProperties.stringPropertyNames() if key.startsWith(" spark.5425." ))
146+ System .getProperties.remove(key)
147+ }
148+ }
124149}
You can’t perform that action at this time.
0 commit comments