FilterOutputStream.close() throws exception from flush()

Alex Lam S.L. alexlamsl at
Fri Feb 10 13:52:36 UTC 2012

Hi there,

Thanks for the pointer - I wasn't able to trace back to that email for
some reasons.

The problem is that:

 - flush() is reporting IOException because underlying stream is closed
 - close() is then forwarding that IOException now in JavaSE 8

I guess my question is: what is the best way to check and avoid the
case where OutputStream is already closed?


On Fri, Feb 10, 2012 at 1:46 PM, Alan Bateman <Alan.Bateman at> wrote:
> On 10/02/2012 13:09, Alex Lam S.L. wrote:
>> Hi there,
>> I have some code which calls FilterOutputStream.close(), which calls
>> the underlying OutputStream.flush() which throws IOException.
>> With previous versions of JavaSE, close() returns successfully without
>> any problems.
>> Using JDK8-b24, I get an IOException which is propagated from flush().
>> Is there any reason for this change in behaviour?
>> Regards,
>> Alex.
> This was deliberate change as FilterOutputStream.close was silently ignoring
> the exception from the flush (a serious bug in my view). In the original
> discussion [1] I noted that we may have to consider a compatible switch in
> the event that it causes problems for applications that don't expect close
> to fail. You may be the first.
> -Alan
> [1]

More information about the core-libs-dev mailing list