Thread synchronization issue. Leads to ConcurrentModification Exception....

... Exposed by Spark.

The fix is to move HashSet initialization to the synchronized block right above it.