On Fri, 12 Nov 2021 09:12:07 GMT, Masanori Yano <my...@openjdk.org> wrote:
>> Could you please review the 8262297 bug fixes? >> >> In this case, ImageIO.write() should throw java.io.IOException rather than >> java.lang.IndexOutOfBoundsException. IndexOutOfBoundsException is caught and >> wrapped in IIOException in ImageIO.write() with this fix. In addition, >> IndexOutOfBoundsException is not expected to throw by >> RandomAccessFile#write() according to its API specification. So it should be >> fixed. > > Masanori Yano has updated the pull request incrementally with two additional > commits since the last revision: > > - 8262297: ImageIO.write() method will throw IndexOutOfBoundsException > - 8262297: ImageIO.write() method will throw IndexOutOfBoundsException src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java line 1459: > 1457: int biType = imgType.getBufferedImageType(); > 1458: int bpp = imgType.getColorModel().getPixelSize(); > 1459: if (bpp != 0 && bpp != 1 && bpp != 4 && bpp != 8 && bpp != 16 > && bpp != 24 && bpp != 32) { This change looks good to me. test/jdk/javax/imageio/plugins/bmp/TruncatedPngTest.java line 27: > 25: * @test > 26: * @bug 8262297 > 27: * @summary Checks that ImageIO.write(..., ..., File) truncates the file I think with latest patch this summary should be updated to reflect what test is verifying. test/jdk/javax/imageio/plugins/bmp/TruncatedPngTest.java line 41: > 39: > 40: public static void main(String[] args) { > 41: String fileName = "0.png"; A 2KB image will not take much space but it would be better if we can create 2bpp PNG image programmatically and use it in the test case. ------------- PR: https://git.openjdk.java.net/jdk/pull/6151