Fix NullPointer bug if attribute value is null.