private static <T> T doDeepCopy(T o) {
    try {
      HeapDataOutputStream hdos = new HeapDataOutputStream(KnownVersion.CURRENT);
      DataSerializer.writeObject(o, hdos);
      return DataSerializer.readObject(new DataInputStream(hdos.getInputStream()));
    } catch (ClassNotFoundException ex) {
      throw new CopyException(
          String.format("Copy failed on instance of %s", o.getClass()),
          ex);
    } catch (IOException ex) {
      throw new CopyException(
          String.format("Copy failed on instance of %s", o.getClass()),
          ex);
    }

  }
Makes a deep copy of the specified object o using serialization, so the object has to be
serializable by GemFire.

<p>
If o is a {@link #isWellKnownImmutableInstance(Object) well known immutable instance} then it
will be returned without copying it.

<p>
The passed in object is serialized in memory, and then deserialized into a new instance, which
is returned. If GemFire serialization is implemented for the object, it is used; otherwise,
java serialization is used.

@param <T> the type of the object to be copied
@param o the original object to be copied
@return the new instance that is a copy of the original
@throws CopyException if copying fails because a class could not be found or could not be
        serialized
@see #copy(Object)
geode-core/src/main/java/org/apache/geode/CopyHelper.java