RFR: 8294696 - draining buffer instead of falling back to super.transferTo

Markus KARG duke at openjdk.org
Sun Oct 2 18:01:27 UTC 2022


On Sat, 1 Oct 2022 20:29:23 GMT, Markus KARG <duke at openjdk.org> wrote:

> This PR implements JDK-8294696.

I think the leak is actually not a problem. `ByteArrayInputStream::transferTo` does the same BTW, see https://github.com/openjdk/jdk/blob/68da02c7b536799ccca49e889c22f3e9a2691fb7/src/java.base/share/classes/java/io/ByteArrayInputStream.java#L206-L211
In case the wrapped stream would write into the leaked buffer, that "injected" data would be lost, as no replay can happen due to the `mark == -1`  safety check. So unless we remove that check (which is not planned), such "injected" data is never read.

The JavaDoc of `markpos` literally says:

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

PR: https://git.openjdk.org/jdk/pull/10525


More information about the core-libs-dev mailing list