package com.oath.cyclops.internal.stream.spliterators;

import java.util.Iterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Consumer;

/**
 * Created by johnmcclean on 22/12/2016.
 */

public class IteratableSpliterator<T> implements Spliterator<T>, CopyableSpliterator<T>{

    private final Iterable<T> source;

    Spliterator<T> active;

    public IteratableSpliterator(final Iterable<T> source) {
        this.source = source;
    }

    @Override
    public void forEachRemaining(Consumer<? super T> action) {

        if(active==null)
            active = source.spliterator();


        active.forEachRemaining(action);

    }

    @Override
    public Spliterator<T> trySplit() {

        if(active==null)
            active=source.spliterator();

        return active.trySplit();

  }

    @Override
    public long estimateSize() {

        if(active==null)
            active=source.spliterator();

        return active.estimateSize();

    }

    @Override
    public int characteristics() {
      return active.characteristics();
    }

    @Override
    public boolean tryAdvance(Consumer<? super T> action) {

        if(active==null)
            active=source.spliterator();

        return active.tryAdvance(action);

    }

    @Override
    public Spliterator<T> copy() {
        return new IteratableSpliterator<>(source);
    }
}

@@ -1043,24 +1043,86 @@
 ristics() %7B%0A
+%0A      if(active==null)%0A        active=source.spliterator();%0A%0A
       return
@@ -1148,16 +1148,17 @@
 tics();%0A
+%0A
     %7D%0A%0A 

Add the null check/initialization for the characteristics delegation to active as well.