groovy
  1. groovy
  2. GROOVY-5049

File.getText() should close the streams

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.9-beta-4, 1.8.4
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      Performing a lot of system calls causes Groovy to die on Linux with an IOException for "Too many open files". The cause is streams which are left open by system calls:

      (1..n).each

      { "ls".execute().text }

      This method should be changed to close all streams after it gets the text from them.

        Issue Links

          Activity

          Hide
          Uri Moszkowicz added a comment -

          I grabbed groovy-all-1.8.3-SNAPSHOT.jar and placed it into my groovy embeddable directory and renamed it to groovy-all-1.8.2.jar. I then changed the script to use waitForProcessOutput() and ran it in the case showing the error and it still occurs. Did I test it right?

          Show
          Uri Moszkowicz added a comment - I grabbed groovy-all-1.8.3-SNAPSHOT.jar and placed it into my groovy embeddable directory and renamed it to groovy-all-1.8.2.jar. I then changed the script to use waitForProcessOutput() and ran it in the case showing the error and it still occurs. Did I test it right?
          Hide
          Paul King added a comment -

          It depends on how your are running groovy. If you are referencing the groovy-all jar directly (e.g. in an IDE) then you have done the correct steps. If you are using groovy from the commandline or groovyConsole in is likely using the non-all jar in the lib directory.

          Show
          Paul King added a comment - It depends on how your are running groovy. If you are referencing the groovy-all jar directly (e.g. in an IDE) then you have done the correct steps. If you are using groovy from the commandline or groovyConsole in is likely using the non-all jar in the lib directory.
          Hide
          Uri Moszkowicz added a comment -

          The change seems to prevent the exception now.

          Show
          Uri Moszkowicz added a comment - The change seems to prevent the exception now.
          Hide
          Paul King added a comment -

          Cool. Thanks for trying that out. Next we'll have to think about further shorthands! Though perhaps that could be a separate issue given the title of this issue?

          Show
          Paul King added a comment - Cool. Thanks for trying that out. Next we'll have to think about further shorthands! Though perhaps that could be a separate issue given the title of this issue?
          Hide
          Paul King added a comment -

          ok, closing this issue but see GROOVY-5058 for future enhancements

          Show
          Paul King added a comment - ok, closing this issue but see GROOVY-5058 for future enhancements

            People

            • Assignee:
              Paul King
              Reporter:
              Uri Moszkowicz
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: