Fixes #3407: Prevent NPE when publishing event

Fixes #3407: Prevent NPE
So @sancar what are we going to do with this PR?