mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8266857: PipedOutputStream.sink should be volatile
Reviewed-by: dfuchs
This commit is contained in:
parent
381de0c1d0
commit
d0daa72592
1 changed files with 4 additions and 1 deletions
|
@ -49,7 +49,7 @@ public class PipedOutputStream extends OutputStream {
|
||||||
more sophisticated. Either using thread groups (but what about
|
more sophisticated. Either using thread groups (but what about
|
||||||
pipes within a thread?) or using finalization (but it may be a
|
pipes within a thread?) or using finalization (but it may be a
|
||||||
long time until the next GC). */
|
long time until the next GC). */
|
||||||
private PipedInputStream sink;
|
private volatile PipedInputStream sink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a piped output stream connected to the specified piped
|
* Creates a piped output stream connected to the specified piped
|
||||||
|
@ -115,6 +115,7 @@ public class PipedOutputStream extends OutputStream {
|
||||||
* closed, or if an I/O error occurs.
|
* closed, or if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
|
var sink = this.sink;
|
||||||
if (sink == null) {
|
if (sink == null) {
|
||||||
throw new IOException("Pipe not connected");
|
throw new IOException("Pipe not connected");
|
||||||
}
|
}
|
||||||
|
@ -135,6 +136,7 @@ public class PipedOutputStream extends OutputStream {
|
||||||
* closed, or if an I/O error occurs.
|
* closed, or if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public void write(byte b[], int off, int len) throws IOException {
|
public void write(byte b[], int off, int len) throws IOException {
|
||||||
|
var sink = this.sink;
|
||||||
if (sink == null) {
|
if (sink == null) {
|
||||||
throw new IOException("Pipe not connected");
|
throw new IOException("Pipe not connected");
|
||||||
} else if (b == null) {
|
} else if (b == null) {
|
||||||
|
@ -171,6 +173,7 @@ public class PipedOutputStream extends OutputStream {
|
||||||
* @throws IOException if an I/O error occurs.
|
* @throws IOException if an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
|
var sink = this.sink;
|
||||||
if (sink != null) {
|
if (sink != null) {
|
||||||
sink.receivedLast();
|
sink.receivedLast();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue