[Fixed JENKINS-11667] Added null check to prevent NPE