[SPARK-2075][Core] backport for branch-1.2

backport #3740 for branch-1.2

Author: zsxwing <zsxwing@gmail.com>

Closes #3758 from zsxwing/SPARK-2075-branch-1.2 and squashes the following commits:

b57d440 [zsxwing] SPARK-2075 backport for branch-1.2