RFR: 8351110: ImageIO.write for JPEG can write corrupt JPEG for certain thumbnail dimensions [v4]

Alexey Ivanov aivanov at openjdk.org
Fri Apr 4 19:16:52 UTC 2025


On Fri, 4 Apr 2025 19:09:20 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

>> Jeremy Wood has updated the pull request incrementally with two additional commits since the last revision:
>> 
>>  - 8351110: adding a few clarifying comments
>>  - 8351110: changing `catch` statement to support assertEquals's Error
>
> test/jdk/javax/imageio/plugins/jpeg/WriteJPEGThumbnailTest.java line 66:
> 
>> 64:         boolean b2 = new WriteJPEGThumbnailTest(100, 219).run();
>> 65:         if (!(b1 && b2))
>> 66:             System.err.println("Test failed");
> 
> Suggestion:
> 
>         if (!(b1 && b2)) {
>             System.err.println("Test failed");
>             throw new Error("Test failed");
>         }
> 
> Always use braces, even for one-line statement.
> 
> You **must throw an exception**, otherwise the test will never fail from jtreg point of view.
> 
> 
> jdk> ./build/windows-x86_64-server-release/jdk/bin/java -jar ../jtreg/lib/jtreg.jar \
>     -w:./build/jtwork -nr -v \
>     test/jdk/javax/imageio/plugins/jpeg/WriteJPEGThumbnailTest.java
> runner starting test: javax/imageio/plugins/jpeg/WriteJPEGThumbnailTest.java
> runner finished test: javax/imageio/plugins/jpeg/WriteJPEGThumbnailTest.java
> Passed. Execution successful
> Test results: passed: 1
> 
> And I don't have your fix.

The WriteJPEGThumbnailTest.jtr says, the test failed:


----------System.out:(3/74)----------
Testing thumbnail 100x218...
	Test passed
Testing thumbnail 100x219...
----------System.err:(15/1153)----------
javax.imageio.IIOException: Unsupported JPEG process: SOF type 0xc8
        at ...
        at WriteJPEGThumbnailTest.run(WriteJPEGThumbnailTest.java:92)
        at WriteJPEGThumbnailTest.main(WriteJPEGThumbnailTest.java:64)
        at ...
Test failed

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23920#discussion_r2029314805


More information about the client-libs-dev mailing list