Avoid NullPointerException in CustomObjectSerializerImpl