On Sun, 14 Mar 2021 07:51:24 GMT, Alan Bateman <al...@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.
>
> src/java.base/share/classes/jdk/internal/jmod/JmodFile.java line 57:
> 
>> 55:             // validate the header
>> 56:             byte[] magic = new byte[4];
>> 57:             in.read(magic);
> 
> While you are there, this can be changed to magic = in.readNBytes(4) and 
> throw IOException if magic.length != 4.

Done.

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

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

Reply via email to