RFR: 8351108: ImageIO.write(..) fails with exception when writing JPEG with IndexColorModel [v3]
Alexey Ivanov
aivanov at openjdk.org
Mon Mar 10 17:27:55 UTC 2025
On Mon, 10 Mar 2025 17:20:36 GMT, Jeremy Wood <duke at openjdk.org> wrote:
>> Previously ImageTypeSpecifier treated all TYPE_BYTE_INDEXED as if they were opaque.
>>
>> In this ticket's case: an ImageWriter received the wrong ImageTypeSpecifier and mistakenly indicated it *could* support a BufferedImage. But when the actual BufferedImage arrived (which was translucent), the ImageWriter threw an exception.
>>
>> Instead:
>> Now the ImageTypeSpecifier accurately describes the given BufferedImage.
>
> Jeremy Wood has updated the pull request incrementally with five additional commits since the last revision:
>
> - 8351108: adding empty line to bottom of file
>
> This is in response to:
> https://github.com/openjdk/jdk/pull/23884#discussion_r1987278977
> - Merge remote-tracking branch 'origin/JDK-8351108' into JDK-8351108
> - 8351108: replacing wildcard import
>
> This is in response to:
> https://github.com/openjdk/jdk/pull/23884#discussion_r1987268179
> - 8351108: updating copyright year
>
> This is in response to:
> https://github.com/openjdk/jdk/pull/23884#discussion_r1987265582
> - 8351108: changing indentation / line wrapping
>
> This is in response to:
> https://github.com/openjdk/jdk/pull/23884#discussion_r1987265134
test/jdk/javax/imageio/plugins/jpeg/JpegWriterWriteNonOpaqueIndexColorModelTest.java line 40:
> 38:
> 39: public class JpegWriterWriteNonOpaqueIndexColorModelTest {
> 40: public static void main(String[] args) throws IOException {
The `main` method doesn't throw `IOException` so it could be removed from the `throws` clause and imports.
Suggestion:
public static void main(String[] args) {
test/jdk/javax/imageio/plugins/jpeg/JpegWriterWriteNonOpaqueIndexColorModelTest.java line 45:
> 43: boolean b3 = testJpegWriter(Transparency.TRANSLUCENT, "TRANSLUCENT", false);
> 44: if (!(b1 && b2 && b3))
> 45: throw new Error("Test failed");
Suggestion:
if (!(b1 && b2 && b3)) {
throw new Error("Test failed");
}
Missing braces.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23884#discussion_r1987725612
PR Review Comment: https://git.openjdk.org/jdk/pull/23884#discussion_r1987724631
More information about the client-libs-dev
mailing list