Uploaded image for project: 'TinkerPop'
  1. TinkerPop
  2. TINKERPOP-2416

MultiIterator should implement AutoCloseable

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 3.4.8
    • Fix Version/s: 3.5.0, 3.4.9
    • Component/s: structure
    • Labels:
      None

      Description

      TinkerPop has a handy set of util methods for Iterators and specifically IteratorUtils#concat provides a way to combine multiple iterators and treat it as if we have a single iterator.

      https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/iterator/IteratorUtils.java#L352

      While this is convenient, when we use it we had some memory leak issue.
      The reason is because sometimes an iterator we use needs to be explicitly closed when it holds underlying resource to be released. TinkerPop is aware of this pattern and it has CloseableIterator#closeIterator method that closes an iterator if it implements AutoCloseable.

      However MultiIterator which Tinkerpop uses to combine multiple iterators when concat method is called does not implement AutoCloseable therefore when we use concat method while expecting the iterator is eventually closed by CloseableIterator#closeIterator method, it leaves the underlying iterators unclosed then it causes some resources never released.

        Attachments

          Activity

            People

            • Assignee:
              spmallette Stephen Mallette
              Reporter:
              redtree1112 Norio Akagi
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: