Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4174670

java.io.ByteArrayOutputStream: write on closed stream throws RuntimeException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • generic
    • generic

      If I issue a PrintWriter.print() where the PrintWriter is based on a ByteArrayOutputStream and that stream is closed, I see the following exception:

      Exception in thread "main" java.lang.RuntimeException: Stream closed
              at java.io.ByteArrayOutputStream.ensureOpen(Compiled Code)
              at java.io.ByteArrayOutputStream.write(Compiled Code)
              at java.io.OutputStreamWriter.flushBuffer(Compiled Code)
              at java.io.OutputStreamWriter.flush(Compiled Code)
              at java.io.BufferedWriter.flush(Compiled Code)
              at java.io.PrintWriter.flush(Compiled Code)
              at java.io.PrintWriter.checkError(Compiled Code)
              at bugDemo.main(Compiled Code)

      This is new behavior in the JDK1.2 This same program did not throw an exception in JDK1.1 (see also bug 4153007, which fixed a different symptom related to this same operation).

            mr Mark Reinhold
            kdonkersunw Karin Donker (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: