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)
======================================================================
- relates to
-
JDK-8305748 Clarify reentrant behavior of close() in FileInputStream, FileOutputStream, and RandomAccessFile
-
- Resolved
-