[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

(cherry picked from commit 080ceb771a1e6b9f844cfd4f1baa01133c106888)
Signed-off-by: Patrick Wendell <pwendell@gmail.com>