[SPARK-4952][Core]Handle ConcurrentModificationExceptions in SparkEnv.environmentDetails

Author: GuoQiang Li <witgo@qq.com>

Closes #3788 from witgo/SPARK-4952 and squashes the following commits:

d903529 [GuoQiang Li] Handle ConcurrentModificationExceptions in SparkEnv.environmentDetails