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