YARN-2602. Fixed possible NPE in ApplicationHistoryManagerOnTimelineStore. Contributed by Zhijie Shen
(cherry picked from commit bbff96be48119774688981d04baf444639135977)