On Fri, 7 Jan 2022 00:01:24 GMT, Kevin Rushforth <k...@openjdk.org> wrote:

>> Michael Strauß has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Added test for image format without signature
>
> modules/javafx.graphics/src/main/java/com/sun/javafx/iio/ImageStorage.java 
> line 490:
> 
>> 488:         if (stream.read(header) <= 0) {
>> 489:             return null;
>> 490:         }
> 
> What was the reason for this change? The former would work even if the stream 
> returned less data that the size of the header in a single read, whereas the 
> latter would fail.

Well, almost. `ImageTools.readFully` throws `EOFException` if the input stream 
is empty. That doesn't make a lot of sense in the context of 
`getLoaderBySignature`, since the method should return `null` if the input 
stream doesn't contain enough data to detect a signature (and it doesn't seem 
useful to me to make a distinction between "not enough" bytes and zero bytes). 
I've opted to retain the use of `ImageTools.readFully`, but catch the 
`EOFException` and return `null` instead.

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

PR: https://git.openjdk.java.net/jfx/pull/676

Reply via email to