RFR: 8364135: JPEGImageReader.getImageTypes() should throw exception for negative image index [v2]

Phil Race prr at openjdk.org
Thu Aug 21 20:48:55 UTC 2025


On Thu, 21 Aug 2025 04:58:12 GMT, Jayathirth D V <jdv at openjdk.org> wrote:

>> We need to throw appropriate exception when we pass invalid image index values to ImageReader.getImageTypes().
>> We throw IOOBE in all other plugins except JPEG, Added appropriate check to throw IOOBE when JpegImageReader has invalid image index.
>
> Jayathirth D V has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
> 
>  - Update test to handle all regression cases
>  - Add checks at other places also
>  - Merge remote-tracking branch 'upstream/master' into jpeg_getImageTypes
>  - Check only for negative index
>  - 8364135: JPEGImageReader.getImageTypes() should throw exception for non-zero image index

Marked as reviewed by prr (Reviewer).

test/jdk/javax/imageio/plugins/jpeg/JpegNegativeImageIndexTest.java line 60:

> 58:             ImageTypeSpecifier specifier = ir.getRawImageType(-1);
> 59:         } catch (IndexOutOfBoundsException e) {
> 60:             if (Objects.equals(e.getMessage(), "imageIndex < 0")) {

A bit fragile checking the exception text, but I suppose it won't be changed unless this test changes too.

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

PR Review: https://git.openjdk.org/jdk/pull/26522#pullrequestreview-3142229936
PR Review Comment: https://git.openjdk.org/jdk/pull/26522#discussion_r2292101727


More information about the client-libs-dev mailing list