RFR: 8364768: JDK javax.imageio ImageWriters do not all flush the output stream
Prasanta Sadhukhan
psadhukhan at openjdk.org
Wed Aug 20 12:34:42 UTC 2025
On Fri, 8 Aug 2025 17:31:03 GMT, Phil Race <prr at openjdk.org> wrote:
> 4 of the 6 JDK ImageWriters flush the stream at the end of writing. 2 (TIFF and GIF) do not.
>
> This will matter if you are using a caching ImageOutputStream.
>
> This fix makes it consistent.
src/java.desktop/share/classes/com/sun/imageio/plugins/gif/GIFImageWriter.java line 737:
> 735: writeTrailer();
> 736: }
> 737: stream.flush();
should we call flush or `flushBefore`(current stream position) as is being done in BMP writer?
test/jdk/javax/imageio/FlushTest.java line 2:
> 1: /*
> 2: * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
2025?
test/jdk/javax/imageio/FlushTest.java line 76:
> 74: failed = true;
> 75: }
> 76: } finally {
no need for finally block or do we need to do `baos.close` here since FileCacheImageOutputStream.close says "The destination OutputStream is not closed."
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26703#discussion_r2288019130
PR Review Comment: https://git.openjdk.org/jdk/pull/26703#discussion_r2287987561
PR Review Comment: https://git.openjdk.org/jdk/pull/26703#discussion_r2287988788
More information about the client-libs-dev
mailing list