RFR: 8266857: PipedOutputStream.sink should be volatile

Daniel Fuchs dfuchs at openjdk.java.net
Tue May 11 10:23:24 UTC 2021


On Mon, 10 May 2021 23:25:46 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

> 8266857: PipedOutputStream.sink should be volatile

For correctness (and peace of mind)- we should probably introduce a local variable in all the places where `sink` is read more than once outside of a synchronized block (the two `write` and `close` methods).
I'd suggest simply inserting a first line in each of these methods:


    var sink = this.sink;


This will ensure that there's only one volatile read.

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

PR: https://git.openjdk.java.net/jdk/pull/3960


More information about the core-libs-dev mailing list