On Mon, 25 Aug 2025 14:12:05 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> Jayathirth D V has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Update image index verification function name
>
> src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
>  line 848:
> 
>> 846:     public int getWidth(int imageIndex) throws IOException {
>> 847:         verifyImageIndex(imageIndex);
>> 848:         setThreadLock();
> 
> I wonder whether accessing `minIndex` inside `verifyImageIndex` requires a 
> lock.

That's a good thing to do.
I have updated code to call `verifyImageIndex()` within threadlock. Also we 
don't need to lock the thread for gotoImage()-> `verifyImageIndex()` as the 
call is reaching gotoImage() under a threadlock or callback lock.

> 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")) {
> 
> If we don't iterate over all readers but only the first one, throw the error 
> before the `catch` block.
> 
> Inside the catch block, if the message isn't equal to the expected one, throw 
> the error right away.
> 
> This allows removing indirection of using the `passed` field.

I have updated the test to be more robust and check for all functions calls now.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26522#discussion_r2299849096
PR Review Comment: https://git.openjdk.org/jdk/pull/26522#discussion_r2299849842

Reply via email to