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

Alan Bateman alanb at openjdk.org
Sat Oct 29 07:41:16 UTC 2022


On Sun, 23 Oct 2022 08:40:35 GMT, Markus KARG <duke at openjdk.org> wrote:

> Silly me, you are certainly right! I have modified the code as you proposed, so now we should be safe, finally. :-)

The updated version (7350a533) looks safe but it makes for a more complicated transferTo so it would be good to see updated performance results. One thing to look at is dropping the allocation of the new buffer after the writing of the buffered bytes. The transferTo method will read to EOF and should be rare to continue reading after EOF - if there is reading after EOF then this should cause the internal buffer to resize. The optimization is limited to the case where BIS is not extended so there are no subclasses that can observe that the internal buf has shrunk.

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

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


More information about the core-libs-dev mailing list