TRUNK-3970: Fix NPE
(cherry picked from commit 96fb5b042328eb055ee3c66496f2937cad2dad9d)