SPARK-1878: Fix the incorrect initialization order

JIRA: https://issues.apache.org/jira/browse/SPARK-1878