BufferedWriter.write does not throw exception if it is already closed.
lvjing at linux.vnet.ibm.com
Fri Jan 28 05:25:41 UTC 2011
于 2011-1-26 0:19, Alan Bateman 写道:
> Jing LV wrote:
>> I find a problem in java.io.BufferedWriter. It is stated in the java
>> spec of its close() method:
>> "... Once the stream has been closed, further write() or flush()
>> invocations will cause an IOException to be thrown."
>> However if a BufferedWriter is created with a delegated writer, then it
>> seems to "forget" to throw IOException when it's closed, even if the
>> delegated writer wants to. Here is a simple example:
> It's possible we have a spec issue in that BufferedWriter (and others)
> don't specify what their state is in event that flushing or closing
> the underlying Writer fails (the test is assuming that it is closed
> even though the close method failed).
(Sorry for late reply that it seems my mail-box has some trouble that I
cannot send my mail yesterday). I agreed with you that the document may
be changed. However as you see another problem is that the write method
is unstable, it may or may not throw the exception, only depends on its
buffer size, I think we'd better at least fix this unpredictable behaviour?
More information about the core-libs-dev