@Override
        public FetchEmitTuple next() {
            if (next == COMPLETED_SEMAPHORE) {
                throw new IllegalStateException(
                        "don't call next() after hasNext() has returned false!");
            }
            FetchEmitTuple ret = next;
            next = pollNext();
            return ret;
        }
Abstract class that handles the testing for timeouts/thread safety
issues.  Concrete classes implement the blocking {@link #enqueue()}.
If there's an exception in the enqueuing thread, this will throw
a RuntimeException.  It will throw an IllegalStateException if
next() is called after hasNext() has returned false.
tika-core/src/main/java/org/apache/tika/pipes/pipesiterator/PipesIterator.java