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

XMLWordPrintable

    • Type: Bug
    • Resolution: Cannot Reproduce
    • Priority: P4
    • None
    • Affects Version/s: 1.2.0
    • Component/s: 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).

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: