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

Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.io.IOException: Cannot run program "find": java.io.IOException: error=24, Too many open files

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.2, 2.1.0-beta-1
    • groovy-jdk
    • None
    • Patch

    Description

      A script I wrote starts many processes but all within a common GPars pool so no more than a few are running at a time. It fails with the following error:

      Caught: java.util.concurrent.ExecutionException: org.codehaus.groovy.runtime.InvokerInvocationException: org.codehaus.groovy.runtime.InvokerInvocationException: java.io.IOException: Cannot run program "find": java.io.IOException: error=24, Too many open files

      I verified that the problem is fixed by calling process.out.close() after every Process finishes. However, this solution is undesirable for a few two reasons. First, it adds an extra possibly avoidable line. Second, it prevents usage of convenience methods like getText(), where the Process might not have been exposed.

      The fix works because the Process remains open as long as STDIN is open. I see that STDOUT and STDERR are closed already so probably someone tried to fix this problem in the past but closed the wrong streams. To fix the problem, I propose that the STDIN (out) stream be closed as well where those streams are already closed. Additionally, I propose adding the close() calls to getText() as well.

      I've attached a diff with the change for review. I rebuilt Groovy and verified that the script no longer fails with these changes. A unit test is still needed but haven't delved into that part of Groovy source quite yet

      Attachments

        1. diff.log
          2 kB
          Uri Moszkowicz

        Activity

          People

            guillaume Guillaume Sauthier
            balor123 Uri Moszkowicz
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: