SPARK-1878: Fix the incorrect initialization order

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

Author: zsxwing <zsxwing@gmail.com>

Closes #822 from zsxwing/SPARK-1878 and squashes the following commits:

4a47e27 [zsxwing] SPARK-1878: Fix the incorrect initialization order

(cherry picked from commit 1811ba8ccb580979aa2e12019e6a82805f09ab53)
Signed-off-by: Tathagata Das <tathagata.das1565@gmail.com>