Jira 3074 - check for null

TBH I didn't test it, but this looks like it should do the trick.