cassandra
cassandra copied to clipboard
Fix RangeIntersectionIterator resource leak/superfluous wrapping of input iterator
These were regressions introduced several months ago in the implementation of improved query planning. The build method originally took a ranges
argument that was called with rangeIterators
, so these correctly referred to the argument. When these arguments were removed, ranges
started referring to a field of the parent RangeIterator.Builder
class.
@michaeljmarshall @pkolaczk Git blame suggests you both as reviewers here but feel free to point me elsewhere if you don't have bandwidth.
Michael's comments inspired me to realize that Plan.Intersection and Plan.Union would call ranges()
if an exception is thrown during execute, returning the empty RangeIterator ranges
to be closed and leaking iterators. Since no classes extending RangeIterator.Builder ever actually use the ranges
field and they all override add methods to use their own collections, I removed this from RangeIterator.Builder entirely, preventing us from making this mistake.