RFR: 4799358: BufferOutputStream.write() should immediately throw IOExcept on closed stream [v2]
Vyom Tewari
vtewari at openjdk.org
Thu Aug 24 04:27:24 UTC 2023
On Wed, 23 Aug 2023 21:54:31 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> The proposed change does not appear to add a great deal of value and breaks longstanding behavior. In such cases, the preferred approach is usually to modify the specification to match the current, albeit incorrect, behavior rather than to change the code itself. Given that this issue was filed more than two decades ago suggests that changing the implementation would be likely to break code which unwittingly depends on the longstanding behavior.
I am unable to understand how proposed change breaks longstanding behavior(what behavior). With current implementation if the underline stream is closed ‘BufferedOutputStream.write’ will throw IOException when the internal buffer is full. With the proposed change BufferedOutputStream will throw IOException immediately . I don’t see any reason in not throwing exception and waiting till internal buffer fills.
All other OutputStream implementations internally checks and throw IOException immediately if the stream is close. So with the proposed change 'BufferedOutputStream' will behave the same.
Do you really think there is code outside which do ‘write’ after closing the stream, and proposed change will break it ?.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15361#issuecomment-1690976782
More information about the core-libs-dev
mailing list