RFR: 8190753: (zipfs): Accessing a large entry (> 2^31 bytes) leads to a negative initial size for ByteArrayOutputStream [v8]
Jaikiran Pai
jai.forums2013 at gmail.com
Thu Jul 22 16:01:46 UTC 2021
Hello Bernd,
On 22/07/21 8:54 pm, Bernd Eckenfels wrote:
> Hello,
>
>> So although you can transfer the contents to the file without requiring the access
>> to the byte array, you end up creating a new copy of that array (through the use
>> of `baos.toByteArray()`)
> You can avoid the copy and the additional buffer with baos.writeTo() I think.
>
> try (OutputStream os = Files.newOutputStream(entry.file)) { // maybe append?
> baos.writeTo(os);
> }
You are absolutely right. I hadn't noticed ByteArrayOutputStream had
this writeTo() method. Thank you for this input.
This was the only concern I had when it came to wrapping the
ByteArrayOutputStream and now with your input it no longer is a concern.
I have updated this PR to go ahead with the wrapping approach which also
does away with the necessity of UncheckedIOException. Existing and the
new tests continue to pass with this change.
-Jaikiran
More information about the nio-dev
mailing list