RFR of 8180451: ByteArrayInputStream should override readAllBytes, readNBytes, and transferTo
David Lloyd
david.lloyd at redhat.com
Wed Mar 21 20:25:33 UTC 2018
Sorry. This looks OK to me (non-reviewer) now.
On Wed, Mar 21, 2018 at 1:01 PM, Brian Burkhalter
<brian.burkhalter at oracle.com> 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/
>
>
--
- DML
More information about the core-libs-dev
mailing list