Fix possible NPE reported in JENKINS-23841