Fixed NPE.
(cherry picked from commit bf8f846)