On Wed, 9 Apr 2025 17:03:26 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

>> Jeremy Wood has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   8351913: code cleanup
>>   
>>   This is in response to:
>>   https://github.com/openjdk/jdk/pull/23920#discussion_r2029297962
>
> test/jdk/javax/imageio/plugins/jpeg/WriteJPEGThumbnailTest.java line 86:
> 
>> 84:                 thumbnail = writeImage(byteOut);
>> 85:                 jpegData = byteOut.toByteArray();
>> 86:             }
> 
> For `ByteArrayOutputStream`, it should be okay to convert it before the 
> stream is closed, and the stream is closed by `writeImage` anyway. However, 
> placing `jpegData = byteOut.toByteArray()` after the try-with-resources for 
> `byteOut` won't raise any questions. Then, `jpegData` can be declared where 
> it's assigned.

If I understood you correctly:
I couldn't place `jpegData = byteOut.toByteArray()` after the 
try-with-resources block because `byteOut` fell out of scope.

But if the priority is to declare variables where they're assigned: I can just 
remove that inner try-with-resources block. (This is updated.)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23920#discussion_r2035875168

Reply via email to