RFR: 8287102: ImageReaderSpi.canDecodeInput() for standard plugins should return false if a stream is too short [v2]

Martin Desruisseaux duke at openjdk.java.net
Tue May 24 07:51:46 UTC 2022


On Tue, 24 May 2022 01:28:29 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> Martin Desruisseaux has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Test all plugins, not only "BMP".
>
> src/java.desktop/share/classes/com/sun/imageio/plugins/common/ReaderUtil.java line 284:
> 
>> 282:         } while (offset < b.length);
>> 283:         return true;
>> 284:     }
> 
> Any reason not to catch EOFException exception in the exceptional situation?

No strong reason. I thought it was safer because a -1 return value means that the stream reached EOF on normal condition, while `EOFException` could still be a problem with the stream for example if the stream wraps another `InputStream` for applying decompression on-the-fly (e.g. a ZIP file), and the compressed stream is truncated before the end of the compression chunk.

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

PR: https://git.openjdk.java.net/jdk/pull/8700



More information about the client-libs-dev mailing list