[OpenJDK 2D-Dev] RFR: 8263560: Remove needless wrapping with BufferedInputStream [v5]

Daniel Fuchs dfuchs at openjdk.java.net
Mon Mar 15 15:08:10 UTC 2021


On Mon, 15 Mar 2021 12:19:19 GMT, Сергей Цыпанов <github.com+10835776+stsypanov at openjdk.org> wrote:

>> In some cases wrapping of `InputStream` with `BufferedInputStream` is redundant, e.g. in case the wrapped one is `ByteArrayOutputStream` which does not require any buffer having one within.
>> 
>> Other cases are related to reading either a byte or short `byte[]`: in both cases `BufferedInputStream.fill()` will be called resulting in load of much bigger amount of data (8192 by default) than required.
>
> Сергей Цыпанов has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix error message

Changes requested by dfuchs (Reviewer).

src/java.base/share/classes/sun/net/www/http/HttpClient.java line 434:

> 432:                 int r = tmpbuf.read();
> 433:                 if (r == -1) {
> 434:                     logFinest("HttpClient.available(): " +

There are some subtle things going on there. Using a `BufferedInputStream` ensures that all the bytes available on the socket will be read, up to the buffer capacity. Can you revert this change? I'd rather that this clean up be handled separately. I have logged https://bugs.openjdk.java.net/browse/JDK-8263599.

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

PR: https://git.openjdk.java.net/jdk/pull/2992


More information about the 2d-dev mailing list