RFR: 8310530: PipedOutputStream.flush() accesses sink racily [v2]

Sergey Tsypanov stsypanov at openjdk.org
Thu Jun 22 13:26:02 UTC 2023


On Wed, 21 Jun 2023 14:58:35 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> On second thought, this is probably not necessary; write to the sink field is in another synchronized method, and this method is synchronized already. Is the goal here to remove the synchronized on flush?
>
> Good observation. Removing `synchronized` on flush might be a worthwhile goal but possible side effects (including on potential subclasses) should be carefully considered.
> I support stashing `sink` in a local variable though, even if the pointer can't be concurrently modified, just to make it clear that we only have one volatile read.

I think it's better to keep `synchronized` over the method this far

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14589#discussion_r1238524265


More information about the core-libs-dev mailing list