apache/incubator-spark — pull request #116 by stephenh (2013-10-27 18:46:32+00:00)
Title: Avoid ConcurrentModificationException in SparkContext init.

Previously, the code used System.getProperties.toMap, but the toMap
converter used Hashtable's iterator, which will fail fast if
concurrently modified:

Caused by: java.util.ConcurrentModificationException
at java.util.Hashtable$Enumerator.next(Hashtable.java:1200)
at scala.collection.JavaConversions$JPropertiesWrapper$$anon$3.next(JavaConversions.scala:933)
at scala.collection.JavaConversions$JPropertiesWrapper$$anon$3.next(JavaConversions.scala:930)
at scala.collection.Iterator$class.foreach(Iterator.scala:660)
at scala.collection.JavaConversions$JPropertiesWrapper$$anon$3.foreach(JavaConversions.scala:930)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:73)
at scala.collection.JavaConversions$JPropertiesWrapper.foreach(JavaConversions.scala:903)
at scala.collection.TraversableOnce$class.toMap(TraversableOnce.scala:256)
at scala.collection.JavaConversions$JPropertiesWrapper.toMap(JavaConversions.scala:903)
at org.apache.spark.SparkContext.(SparkContext.scala:251)

(One of the scheduler/ui threads that is started a few lines before this
is likely doing a System.setProperty.)

Per the javadocs, Hashtable.entrySet will not fail-fast. Technically the behavior during
concurrent modification is undefined, which I suppose could mean dropped
values, but I am hoping/assuming it is more benign.