RFR: 8263560: Remove needless wrapping with BufferedInputStream

Сергей Цыпанов github.com+10835776+stsypanov at openjdk.java.net
Sun Mar 14 17:09:20 UTC 2021


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.

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

Commit messages:
 - Use InputStream.readNBytes()
 - Drop unnecessary BufferedInputStream-wrapping where possible

Changes: https://git.openjdk.java.net/jdk/pull/2992/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2992&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8263560
  Stats: 14 lines in 3 files changed: 2 ins; 7 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/2992.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/2992/head:pull/2992

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


More information about the net-dev mailing list