BZ 1138805 - NPE check
(cherry picked from commit 0a87c043f2088934f3b66488c87f14e7b83b9e17)