RFR: 8351110: ImageIO.write for JPEG can write corrupt JPEG for certain thumbnail dimensions [v4]
Jeremy Wood
duke at openjdk.org
Sat Apr 5 05:51:50 UTC 2025
On Fri, 4 Apr 2025 19:14:00 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:
>> 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` file 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
Thank you for pointing out the `new Error` oversight.
> The WriteJPEGThumbnailTest.jtr file says, the test failed
That output is exactly what I would expect to see before this PR. Is it possible you ran the test without invoking `make`?
When I run this test my jtr file includes:
----------messages:(8/301)----------
command: main WriteJPEGThumbnailTest
reason: User specified action: run main WriteJPEGThumbnailTest
started: Sat Apr 05 01:24:48 EDT 2025
Mode: othervm
Additional options from @modules: --add-modules java.desktop
Process id: 63942
finished: Sat Apr 05 01:24:49 EDT 2025
elapsed time (seconds): 1.248
----------configuration:(3/40)----------
Boot Layer
add modules: java.desktop
----------System.out:(4/84)----------
Testing thumbnail 100x218...
Test passed
Testing thumbnail 100x219...
Test passed
----------System.err:(1/15)----------
STATUS:Passed.
----------rerun:(24/1876)*----------
(I tested both before and after the revisions of the last 24 hrs.)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23920#discussion_r2029711483
More information about the client-libs-dev
mailing list