RFR: 8315351: Rid synchronization in PipedInputStream.close() in favour of benign race
Sergey Tsypanov
stsypanov at openjdk.org
Wed Aug 30 09:58:26 UTC 2023
Assuming that the value written into `in` is always `-1` we can rid synchronized block in favour of guarding `in = - 1` with writing into volatile `closedByReader `:
public void close() throws IOException {
closedByReader = true;
synchronized (this) {
in = -1;
}
}
-->
public void close() throws IOException {
in = -1;
closedByReader = true;
}
-------------
Commit messages:
- Drop redundant synchronization from PipedInputStream.close()
Changes: https://git.openjdk.org/jdk/pull/15486/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15486&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8315351
Stats: 6 lines in 1 file changed: 1 ins; 3 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/15486.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/15486/head:pull/15486
PR: https://git.openjdk.org/jdk/pull/15486
More information about the core-libs-dev
mailing list