RFR: 8289572: InputStream wrapping with BufferedInputStream is redundant in HttpTimestamper

Daniel Fuchs dfuchs at openjdk.org
Fri Jul 1 09:17:39 UTC 2022


On Fri, 1 Jul 2022 08:06:10 GMT, Сергей Цыпанов <duke at openjdk.org> wrote:

> In case we read all bytes from an InputStream we don't need wrapping with BufferedInputStream as the bytes are not written into internal buffer. With removal of redundant buffer we save 8 kB of allocated memory.

I believe that in that case the bytes might get double buffered, depending on whether the buffer used by `readAllBytes` is bigger than the buffer used by  `BufferedInputStream`, since IIAMNM `readAllBytes()` will call `read(byte[], off, len)` - but I otherwise agree that regardless of that wrapping in a `BufferedInputStream` is always wasteful in this case. Good find!

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

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



More information about the security-dev mailing list