InputStream/OutputStream concurrency guarantees
Archie Cobbs
archie.cobbs at gmail.com
Thu Oct 30 17:36:40 UTC 2025
On Thu, Oct 30, 2025 at 12:11 PM Florian Weimer <fweimer at redhat.com> wrote:
> > Also, since there aren't any consistency effects in place, it is not
> > deterministic which changes made by the writer would be seen by the
> > reader/copier.
>
> Sure, but if a defensive copy were made, at least the output would be
> internally consistent.
I think this is still missing the bigger picture. I.e., what is "internally
consistent" supposed to mean? As Pavel said:
the array may be changed while it's being copied, which is no different
> from it being changed while it is being written from.
>From a "consistency" point of view, I think the array behaves essentially
as a bunch of unrelated 8-bit quantities, all of which are subject
to change, in any order. Even if the adversarial writers were writing in
some order, the OutputStream method won't necessarily observe those writes
in that same order (actually I am not 100% certain, but I'm pretty sure
the memory model doesn't guarantee that). So it doesn't matter if
OutputStream happens to read the array from 0 to N - that doesn't really
impose any "order" so to speak.
-Archie
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20251030/7746c88b/attachment.htm>
More information about the core-libs-dev
mailing list