CollectingBarrierStep bug

Anyone ever notice this bug in the CollectingBarrierStep?

Offending line https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/CollectingBarrierStep.java#L81

    @Override
    public boolean hasNextBarrier() {
        this.processAllStarts();
        return !this.traverserSet.isEmpty();
    }


The problem here is that if you had an input of X + Y elements where X is your collecting barrier size and Y is some number greater than 0, if the first X elements in the barrier have no results output in the barrier and the latter Y elements in the barrier do have some result, the barrier will only be called on the first X elements and will not execute a second time.
GitHub
Apache TinkerPop - a graph computing framework. Contribute to apache/tinkerpop development by creating an account on GitHub.
Solution
Overriding this function seems to fix

    @Override
    public Traverser.Admin<Vertex> processNextStart() {
        try {
            return super.processNextStart();
        } catch (final NoSuchElementException e) {
            if (!this.starts.hasNext())
                throw e;
            return EmptyTraverser.instance();
        }
    }
Was this page helpful?