RFR: 4799358: BufferOutputStream.write() should immediately throw IOExcept on closed stream [v2]
Brian Burkhalter
bpb at openjdk.org
Wed Aug 23 22:06:53 UTC 2023
On Wed, 23 Aug 2023 15:01:06 GMT, Vyom Tewari <vtewari at openjdk.org> wrote:
>> With the current implementation of BufferedOutputStream if you close the stream and try to write to the closed stream BufferedOutputStream does not throw an IOException until the internal buffer is full. To fix this issue i added a private "ensureOpen" function to BufferedOutputStream which will check if the underline stream is open. If the underline stream is closed "ensureOpen" will throw the IOException.
>
> Vyom Tewari has updated the pull request incrementally with one additional commit since the last revision:
>
> make the isOpen method to package private
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.
The PR title should be changed to match the JBS issue summary.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15361#issuecomment-1690696492
PR Comment: https://git.openjdk.org/jdk/pull/15361#issuecomment-1690702429
More information about the core-libs-dev
mailing list