RFR: 8330748: ByteArrayOutputStream.writeTo(OutputStream) pins carrier [v2]

Brian Burkhalter bpb at openjdk.org
Tue Apr 23 18:11:29 UTC 2024


On Tue, 23 Apr 2024 17:35:42 GMT, Jason Mehrens <duke at openjdk.org> wrote:

>> A good question. The buf/count fields are protected so the subclass has direct access to the bytes. So while it could Arrays.copy the bytes, it doesn't help with a buggy subclass that is changing bytes without synchronization.
>
> I was thinking more of a subclass that counted invocations to public methods or metering which would cause subclass to double the counts when calling via virtual thread.

So do we think it better not to invoke `toByteArray` here?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18901#discussion_r1576686390


More information about the core-libs-dev mailing list