RFR: 4799358: BufferOutputStream.write() should immediately throw IOExcept on closed stream

Vyom Tewari vtewari at openjdk.org
Mon Aug 21 14:53:28 UTC 2023


On Mon, 21 Aug 2023 14:37:37 GMT, Alan Bateman <alanb 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.
>
> src/java.base/share/classes/java/io/FilterOutputStream.java line 209:
> 
>> 207:      * @return {@code true} if, and only if, this stream is open
>> 208:      */
>> 209:     protected boolean isOpen(){
> 
> Adding a protected method to a public class in an exported packages means this is a new  API, it will require discussion, I don't know if you meant to do this or not.

I thought of this ,but i was not 100% sure. I will create CSR first.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15361#discussion_r1300222044


More information about the core-libs-dev mailing list