public static <E> TreeSet<E> readTreeSet(DataInput in)
      throws IOException, ClassNotFoundException {

    InternalDataSerializer.checkIn(in);

    int size = InternalDataSerializer.readArrayLength(in);
    if (size == -1) {
      return null;
    } else {
      Comparator<? super E> c =
          InternalDataSerializer.readNonPdxInstanceObject(in);
      TreeSet<E> set = new TreeSet<>(c);
      for (int i = 0; i < size; i++) {
        E element = DataSerializer.readObject(in);
        set.add(element);
      }

      if (logger.isTraceEnabled(LogMarker.SERIALIZER_VERBOSE)) {
        logger.trace(LogMarker.SERIALIZER_VERBOSE, "Read TreeSet with {} elements: {}", size, set);
      }

      return set;
    }
  }
Reads a <code>TreeSet</code> from a <code>DataInput</code>.

@param <E> the type contained in the <code>TreeSet</code>
@param in the {@link DataInput} to read from
@return the deserialized <code>TreeSet</code>

@throws IOException A problem occurs while reading from <code>in</code>
@throws ClassNotFoundException The class of one of the <Code>TreeSet</code>'s elements cannot
        be found.

@see #writeTreeSet
geode-core/src/main/java/org/apache/geode/DataSerializer.java