NPE when convert object to bytes

The field value could be null, will get NPE when convert it String then to bytes.