RFR: 8364768: JDK javax.imageio ImageWriters do not all flush the output stream [v2]

Phil Race prr at openjdk.org
Thu Aug 21 19:14:54 UTC 2025


On Wed, 20 Aug 2025 12:31:53 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Phil Race has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8364768
>
> 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?

You mean like BMP does this
            stream.flushBefore(stream.getStreamPosition());

flush() is exactly equivalent to that.

    public void flush() throws IOException {
        flushBefore(getStreamPosition());
    }

> test/jdk/javax/imageio/FlushTest.java line 2:
> 
>> 1: /*
>> 2:  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
> 
> 2025?

typo

> 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."

BAOS doesn't need a close() call to report its size.
I can actually dispense with the whole try block since the method throws IOException

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26703#discussion_r2291906324
PR Review Comment: https://git.openjdk.org/jdk/pull/26703#discussion_r2291906705
PR Review Comment: https://git.openjdk.org/jdk/pull/26703#discussion_r2291916877


More information about the client-libs-dev mailing list