Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1904

Iterators do not close streams

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0, 1.1-beta-1
    • 1.1-beta-2
    • groovy-jdk
    • None

    Description

      iterator() methods for File, Reader, InputStream, and DataInputStream return iterators that do not close their underlying streams. They should do this, to be consistent with iterative closure methods like eachLine() etc. A solution must take in account that a loop can be broken by an exception inside the loop, that is not caused by a resource read operation. Also in this case the resource must be closed.

      See discussion at http://www.nabble.com/File-Iterator-leaves-Reader-open-tf3782079.html.

      To clarify problem a JUnit test case will is attached.

      Attachments

        1. DefaultGroovyMethods-Patch.txt
          6 kB
          Jörg Staudemeyer
        2. DefaultGroovyMethodsFileIteratorTest.groovy
          5 kB
          Jörg Staudemeyer
        3. DefaultGroovyMethodsFileIteratorTest.groovy
          4 kB
          Jörg Staudemeyer

        Activity

          People

            blackdrag Jochen Theodorou
            jstaudemeyer Jörg Staudemeyer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: