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

PrintStream.close repeatedly invoked

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 1.4.0
    • core-libs
    • generic
    • generic



      Name: nt126004 Date: 10/02/2001


      java version "1.4.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)

      In a class that extends java.io.PrintStream, if output is written in the close
      method, prior to calling super.close, the output is written to the underlying
      stream twice. For example, the following program prints "hello, world" twice.

          class foo extends java.io.PrintStream
          {
              public foo(java.io.OutputStream out) {
                  super(out);
              }

              public void close() {
                  println("hello, world");
                  super.close();
              }

              public static void main(String[] args) {
                  new foo(System.out).close();
              }
          }

      The problem seems to be that super.close turns around and calls foo.close again.
      (Review ID: 132937)
      ======================================================================

            Unassigned Unassigned
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: