On Mon, 31 Oct 2022 13:30:13 GMT, Markus KARG <d...@openjdk.org> wrote:

>> This PR implements JDK-8294696.
>
> Markus KARG has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Alternative C + Arrays.copyOfRange()

src/java.base/share/classes/java/io/BufferedInputStream.java line 612:

> 610:             if (avail > 0) {
> 611:                 // Prevent poisoning and leaking of buf
> 612:                 byte[] buffer = Arrays.copyOfRange(getBufIfOpen(), pos, 
> count);

@mkarg , could you please clarify why you added `Arrays.copyOfRange` here?
It seems to be an excessive copy that doesn't help much.

`buf` is `protected` in `BufferedInputStream`, so if someone really wants to 
get hold of the actual buffer, they can subclass `BufferedInputStream` and 
expose the buffer directly.
What do you think of removing `copyOfRange`?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/10525#discussion_r1408775984

Reply via email to