[SPARK-2678][Core] Backport PR #1801 to branch-1.0

Backport  SPARK-2678 fix in PR #1801 to branch-1.0