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

This reverts commit aec8244964e3358a2672a5956f9e739a688d64bf. This commit added a redundant
check but inadvertently changed the return code, causing problems.