FilterOutputStream.close() throws exception from flush() (original) (raw)

Alex Lam S.L. alexlamsl at gmail.com
Fri Feb 10 13:16:27 UTC 2012


I think I have narrowed it down to this changeset:

http://hg.openjdk.java.net/hsx/hotspot-rt/jdk/rev/759aa847dcaf

7015589: (spec) BufferedWriter.close leaves stream open if close of underlying Writer fails

Which no longer catches and ignores the exception thrown by flush():

try (OutputStream ostream = out) { flush(); }

To recover the previous behaviour, I think the following might just work:

try (OutputStream ostream = out) { flush(); } catch (IOException ignored) { }

Regards, Alex.

On Fri, Feb 10, 2012 at 1:09 PM, Alex Lam S.L. <alexlamsl at gmail.com> 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.



More information about the core-libs-dev mailing list