BytesReference usage to properly work when hasArray is not available
when a BytesReference doesn't have a backing array, properly handle the case in places where its applicable
closes #5455