Uploaded image for project: 'Commons Exec'
  1. Commons Exec
  2. EXEC-32

PumpStreamHandler handles null streams inconsistently

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0
    • None

    Description

      Passing null arguments in PumpStreamHandler constructors produces hard-to-understand errors.

      E.g.

        PumpStreamHandler streamHanlder = new PumpStreamHandler(System.out, System.err, null);
      

      works correctly, so you can expect that null is a valid argument.

      Instead

        PumpStreamHandler streamHanlder = new PumpStreamHandler(System.out, null, null);
      

      raise a NullPointerException when Executor.execute() is invoked.
      Note that exception is raised by the start() method of PumpStreamHandler .

      Surprisingly

        PumpStreamHandler streamHanlder = new PumpStreamHandler(null, System.err, null);
      

      starts correctly, but fails with a NullPointerException when the process exits.
      In this case, the exception is raised by the stop() method of PumpStreamHandler .

      I think that the behavior should be more consistent and, if necessary, errors must be reported earlier.
      So I suggest two alternatives:

      • if a null argument is passed to a constructor as stdout/stderr an exception is raised immediately
      • or, if stdout or stderr are set to null, default System.out and System.err are used instead.
        At least, the error should be reported before starting process in every case.

      Attachments

        1. DefaultExecutorTest.patch
          2 kB
          Marco Ferrante
        2. PumpStreamHandler.patch
          2 kB
          Marco Ferrante

        Activity

          People

            sgoeschl Siegfried Goeschl
            mferrante Marco Ferrante
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: