TRQ-2719. Add a null check when encoding an attribute.