public static Object copyAndReleaseIfNeeded(@Released Object v, InternalCache cache) {
    if (v instanceof StoredObject) {
      @Unretained
      StoredObject ohv = (StoredObject) v;
      try {
        if (ohv.isSerialized()) {
          return CachedDeserializableFactory.create(ohv.getSerializedValue(), cache);
        } else {
          // it is a byte[]
          return ohv.getDeserializedForReading();
        }
      } finally {
        release(ohv);
      }
    } else {
      return v;
    }
  }
Just like {@link #copyIfNeeded(Object, InternalCache)} except that if off-heap is copied it is
also released.

@param v If this value is off-heap then the caller must have already retained it.
@return the heap copy to use in place of v
geode-core/src/main/java/org/apache/geode/internal/offheap/OffHeapHelper.java