@Override
  public Iterator<T> iterator() {
    return new Iterator<T>() {

      private final Iterator<T> iterator = new LinkedList<>(snapshot).iterator();
      private T currentElement;

      @Override
      public boolean hasNext() {
        return iterator.hasNext();
      }

      @Override
      public T next() {
        currentElement = iterator.next();
        return currentElement;
      }

      @Override
      public void remove() {
        snapshot.remove(currentElement);
      }

      @Override
      public void forEachRemaining(Consumer<? super T> action) {
        iterator.forEachRemaining(action);
      }
    };
  }
Create a custom {@link Iterator} implementation for the {@link CopyOnWriteHashSet}
geode-core/src/main/java/org/apache/geode/internal/CopyOnWriteHashSet.java