Fixes #3407: Prevent NPE when publishing event

Fixes #3407: Prevent NPE
We have recently make a change in ClientEngine. I will look into this one to figure out if it is normal to get null at this point or not.