RFR of 8180451: ByteArrayInputStream should override readAllBytes, readNBytes, and transferTo

Roger Riggs Roger.Riggs at Oracle.com
Fri Mar 23 15:35:05 UTC 2018


Hi Brian,

Looks fine.

Cosmetically, you could join some of the lines in ByteArrayInputStream 
153-164.

In the test, ReadAllReadNTransferTo.java
53-54:  spaces around "/" and before "-"

No further review needed.

Thanks, Roger

On 3/21/2018 2:01 PM, Brian Burkhalter wrote:
> This is still in need of final approval, assuming it is OK.
>
> Thanks,
>
> Brian
>
> On Mar 14, 2018, at 10:50 AM, Brian Burkhalter <brian.burkhalter at oracle.com> wrote:
>
>> On Mar 14, 2018, at 9:27 AM, David Lloyd <david.lloyd at redhat.com> wrote:
>>
>>> @@ -196,14 +194,32 @@
>>>          return len;
>>>      }
>>>
>>> +    public synchronized byte[] readAllBytes() {
>>> +        byte[] result = Arrays.copyOfRange(buf, pos, count);
>>> +        pos = count;
>>> +        return result;
>>> +    }
>>> +
>>> +    public synchronized int readNBytes(byte[] b, int off, int len) {
>>> +        int n = read(b, off, len);
>>> +        return n == -1 ? 0 : n;
>>> +    }
>>>
>>> This probably doesn't need to be synchronized, though I imagine the
>>> difference would be minimal.
>> You are correct, it does not.
>>
>>> +    public synchronized long transferTo(OutputStream out) throws IOException {
>>> +        int len = count - pos
>>> +        out.write(but, pos, len);
>>>
>>> s/but/buf/ I guess?
>> Webrevs corrected in place:
>>
>> http://cr.openjdk.java.net/~bpb/8180451/webrev.00-01/
>> http://cr.openjdk.java.net/~bpb/8180451/webrev.01/



More information about the core-libs-dev mailing list