RFR: 4799358: BufferOutputStream.write() should immediately throw IOExcept on closed stream
    Chen Liang 
    liach at openjdk.org
       
    Mon Aug 21 15:03:34 UTC 2023
    
    
  
On Mon, 21 Aug 2023 14:26:39 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.
`write(int)` should have an `ensureOpen` check too.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15361#issuecomment-1686499580
    
    
More information about the core-libs-dev
mailing list