RFR: 8282648: Problems due to conflicting specification of Inflater::inflate(..) and InflaterInputStream::read(..) [v2]
Lance Andersen
lancea at openjdk.java.net
Mon Mar 28 18:26:49 UTC 2022
On Mon, 28 Mar 2022 17:21:40 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/zip/InflaterInputStream.java line 133:
>>
>>> 131: * Unlike the {@link InputStream#read(byte[],int,int) overridden method}
>>> 132: * of {@code InputStream}, this method might write more bytes than the returned
>>> 133: * number of inflated bytes into the buffer {@code b}.
>>
>> Hello Volker, I think this comment should be a bit more clear and state what exactly it means by writing more bytes than the returned value. Specifically, I think it should clearly state that even though it might write additional data, it will however not write/change data starting and beyond `off + len` index in the passed array.
>
> I think this require a bit of word smithing. If the return value is 'n' then it should make it clear that the values in elements b[off + n] to b[off + len - 1] are undefined, their values may or may have been changed by the inflate/read operation. For completeness, the expectation for when inflate fails should be specified too, the contents of b[off] to b[off + len - 1] will be undefined.
Hi Volker,
I believe you are heading in the right direction. I agree with Alan and Jai that we could use a bit more clarification
-------------
PR: https://git.openjdk.java.net/jdk/pull/7986
More information about the core-libs-dev
mailing list