Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-5608

BaseTestCase.readProcessOutput should read getInputStream() and getErrorStream() in separate threads

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 10.9.1.0
    • 10.8.3.0, 10.9.1.0
    • Test
    • None

    Description

      BaseTestCase.readProcessOutput() reads the streams from Process.getInputStream() and Process.getErrorStream() sequentially
      InputStream is = pr.getInputStream();
      InputStream es = pr.getErrorStream();
      ...
      output += "<STDOUT> " + inputStreamToString(is) + "<END STDOUT>\n";
      output += "<STDERR>" + inputStreamToString(es) + "<END STDERR>\n";

      I think that to be really correct the two streams need to be read in separate threads because if the error output is large it could block and cause a hang if they are read sequentially like this.

      I noticed during the DERBY-5601 discussion as Myrna referenced in that the addition of draining the error stream caused a different problem (an InterruptException). I don't understand how it could cause that problem but do think a hang blocking on reading the input would be possible if the error output was large enough both before and after the change to add the reading of the error stream sequentially.

      Attachments

        1. derby-5608-2a-clear_interrupt_flag_on_waitFor.diff
          0.8 kB
          Kristian Waagan
        2. derby-5608-1a-use_spawnedprocess.diff
          7 kB
          Kristian Waagan

        Issue Links

          Activity

            People

              kristwaa Kristian Waagan
              kmarsden Katherine Marsden
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: