PrintStream.close repeatedly invoked

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: 1.4.0
    • Component/s: 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)
      ======================================================================

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

              Created:
              Updated:
              Imported:
              Indexed: