RFR: 8310530: PipedOutputStream.flush() accesses sink racily
Chen Liang
liach at openjdk.org
Wed Jun 21 14:30:04 UTC 2023
On Wed, 21 Jun 2023 14:03:23 GMT, Chen Liang <liach at openjdk.org> wrote:
>> Just a tiny clean-up to remove racy read within synchronized method
>
> src/java.base/share/classes/java/io/PipedOutputStream.java line 166:
>
>> 164: @Override
>> 165: public synchronized void flush() throws IOException {
>> 166: PipedInputStream sink = this.sink;
>
> Suggestion:
>
> var sink = this.sink;
>
> As seen in other methods.
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?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14589#discussion_r1237103593
More information about the core-libs-dev
mailing list