On Tue, 3 Nov 2020 08:56:38 GMT, Aleksey Shipilev <sh...@openjdk.org> wrote:
>> InputStream::readNBytes() invokes read(byte[],int,int) repeatedly to load >> bytes into a sequence of intermediate arrays. If an intermediate array is >> not completely filled before being added to the list of arrays the contents >> of which are eventually concatenated to produce the result, then the >> unfilled part of the intermediate array will contribute zeros to the result >> which are not actually in the input. This can occur for example if n < 8192 >> bytes are read into an intermediate array without filling it, and the next >> read() returns zero. It is proposed to detect when an intermediate array is >> only partially full, and to copy the valid range of the array into a new >> array which is instead appended to the list of component arrays. > > This makes sense to me. Looks good to me. ------------- PR: https://git.openjdk.java.net/jdk/pull/1024