RFR: 8294696 - BufferedInputStream.transferTo should drain buffer when mark set

Alan Bateman alanb at openjdk.org
Mon Oct 17 11:16:40 UTC 2022


On Mon, 17 Oct 2022 10:59:21 GMT, Roman Kennke <rkennke at openjdk.org> wrote:

> Which kind of sources would do that, and is there a way to check it and prevent it?
> 
> The whole issue points to an insufficiency in the API: it is lacking a way to transfer buffers in a read-only fashion (like NIO could do). I don't suppose we would want to change that, though, right?

It can arise with many sources. One example is a program writing to a file and another reading from the same file and doing the equivalent of "tail -f". So yes, it is possible for transferTo to transfer >0 bytes after it a previous innovation has returned 0.

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

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


More information about the core-libs-dev mailing list