RFR: 8284638: store skip buffers in InputStream Object [v12]
XenoAmess
duke at openjdk.java.net
Tue May 24 20:40:56 UTC 2022
On Fri, 20 May 2022 21:15:23 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> XenoAmess has updated the pull request incrementally with one additional commit since the last revision:
>>
>> add documents
>
> src/java.base/share/classes/java/io/InputStream.java line 78:
>
>> 76: SoftReference<byte[]> ref = this.skipBufferReference;
>> 77: byte[] buffer;
>> 78: if (ref == null || (buffer = ref.get()) == null || buffer.length < size) {
>
> A comment here or in the method javadoc to the effect that a new buffer is allocated unless the existing buffer is large enough might head off doubt that buffer is always non-null at the return. As would inverting the if:
>
> if (ref != null && (buffer = ref.get()) != null && buffer.length >= size) {
> return buffer;
> }
> // allocate new or larger buffer
> buffer = new byte[size];
> this.skipBufferReference = new SoftReference<>(buffer);
> return buffer;
@RogerRiggs done.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5872
More information about the core-libs-dev
mailing list