File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
src/java.base/share/classes/java/io Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ public class PipedOutputStream extends OutputStream {
4949 more sophisticated. Either using thread groups (but what about
5050 pipes within a thread?) or using finalization (but it may be a
5151 long time until the next GC). */
52- private PipedInputStream sink ;
52+ private volatile PipedInputStream sink ;
5353
5454 /**
5555 * Creates a piped output stream connected to the specified piped
@@ -115,6 +115,7 @@ public synchronized void connect(PipedInputStream snk) throws IOException {
115115 * closed, or if an I/O error occurs.
116116 */
117117 public void write (int b ) throws IOException {
118+ var sink = this .sink ;
118119 if (sink == null ) {
119120 throw new IOException ("Pipe not connected" );
120121 }
@@ -135,6 +136,7 @@ public void write(int b) throws IOException {
135136 * closed, or if an I/O error occurs.
136137 */
137138 public void write (byte b [], int off , int len ) throws IOException {
139+ var sink = this .sink ;
138140 if (sink == null ) {
139141 throw new IOException ("Pipe not connected" );
140142 } else if (b == null ) {
@@ -171,6 +173,7 @@ public synchronized void flush() throws IOException {
171173 * @throws IOException if an I/O error occurs.
172174 */
173175 public void close () throws IOException {
176+ var sink = this .sink ;
174177 if (sink != null ) {
175178 sink .receivedLast ();
176179 }
You can’t perform that action at this time.
0 commit comments