Hi,
 
I've noticed that in most of the code outside of JDK an InputStream taken from FileURLConnection is either read entirely e.g.
in ASM's ClassLoader or passed into Properties where it's read with LineReader (which itself has an internal buffer).
 
Apart from mark/reset activity we need buffering for InputStreams only in case when we read byte by byte which happens seldom
unlike reading with read(byte[], int, int).
 
As soon as BufferedInputStream() allocates its buffer eagerly this means waisting 8 kB of memory per each instance and executing
redundant redundant code involving interaction with volatiles.
 
So my suggestion is to stop wrapping of InputStream with BufferedInputStream from FileURLConnection along
specify explicitly in JavaDoc that an InputStream returned from FileURLConnection.getInputStream() is not buffered
as it is done in Files.newInputStream().
 
Regards,
Sergey Tsypanov

Reply via email to