Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-24 Thread Sergey Tsypanov
On Thu, 23 Mar 2023 21:15:44 GMT, Eirik Bjorsnos wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update src/java.base/share/classes/java/io/BufferedInputStream.java >> >> Co-authored-by: liach <7806504+li..

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Eirik Bjorsnos
On Thu, 23 Mar 2023 19:27:04 GMT, Sergey Tsypanov wrote: >> By default `BufferedInputStream` is constructed with internal buffer with >> capacity 8192. In some cases this buffer is never used, e.g. when we call >> `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`) or when >> `

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Eirik Bjorsnos
On Thu, 23 Mar 2023 19:48:40 GMT, Eirik Bjorsnos wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update src/java.base/share/classes/java/io/BufferedInputStream.java >> >> Co-authored-by: liach <7806504+li..

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Sergey Tsypanov
On Thu, 23 Mar 2023 19:48:40 GMT, Eirik Bjorsnos wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update src/java.base/share/classes/java/io/BufferedInputStream.java >> >> Co-authored-by: liach <7806504+li..

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Sergey Tsypanov
On Thu, 23 Mar 2023 19:55:04 GMT, Alan Bateman wrote: >> src/java.base/share/classes/java/io/BufferedInputStream.java line 183: >> >>> 181: if (buffer == EMPTY) { >>> 182: buf = buffer = new byte[size]; >>> 183: } >> >> You should probably use compareAndSet here too

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Chen Liang
On Thu, 23 Mar 2023 19:27:04 GMT, Sergey Tsypanov wrote: >> By default `BufferedInputStream` is constructed with internal buffer with >> capacity 8192. In some cases this buffer is never used, e.g. when we call >> `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`) or when >> `

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Alan Bateman
On Thu, 23 Mar 2023 19:41:24 GMT, Daniel Fuchs wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update src/java.base/share/classes/java/io/BufferedInputStream.java >> >> Co-authored-by: liach <7806504+li...@

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Chen Liang
On Thu, 23 Mar 2023 19:27:04 GMT, Sergey Tsypanov wrote: >> By default `BufferedInputStream` is constructed with internal buffer with >> capacity 8192. In some cases this buffer is never used, e.g. when we call >> `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`) or when >> `

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Daniel Fuchs
On Thu, 23 Mar 2023 19:53:13 GMT, Chen Liang wrote: > The lazy creation only happens if it's the exact BufferedInputStream class, > which is already handled like the internal lock. Maybe, but how does it play with asynchronous close? - PR Comment: https://git.openjdk.org/jdk/pull/

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Eirik Bjorsnos
On Thu, 23 Mar 2023 19:27:04 GMT, Sergey Tsypanov wrote: >> By default `BufferedInputStream` is constructed with internal buffer with >> capacity 8192. In some cases this buffer is never used, e.g. when we call >> `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`) or when >> `

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Eirik Bjorsnos
On Thu, 23 Mar 2023 19:27:04 GMT, Sergey Tsypanov wrote: >> By default `BufferedInputStream` is constructed with internal buffer with >> capacity 8192. In some cases this buffer is never used, e.g. when we call >> `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`) or when >> `

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Daniel Fuchs
On Thu, 23 Mar 2023 19:27:04 GMT, Sergey Tsypanov wrote: >> By default `BufferedInputStream` is constructed with internal buffer with >> capacity 8192. In some cases this buffer is never used, e.g. when we call >> `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`) or when >> `

Re: RFR: 8304745: Lazily initialize byte[] in java.io.BufferedInputStream [v2]

2023-03-23 Thread Sergey Tsypanov
> By default `BufferedInputStream` is constructed with internal buffer with > capacity 8192. In some cases this buffer is never used, e.g. when we call > `IS.readNBytes()` or `IS.readAllBytes()` (relying on `BIS.read1()`) or when > `BufferedInputStream` is cascaded. Sergey Tsypanov has updated