-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: None
-
Component/s: core-libs
-
b22
When creating a PipedInputStream and PipedOutputStream like the following:
PipedOutputStream out = new PipedOutputStream();
PipedInputStream in = new PipedInputStream(out) ...
PipedOutputStream#connect will be called by the thread with the PipedInputStream and write to the field PipedOutputStream.sink, and that field will be read in the other thread by methods like PipedOutputStream#write.
PipedOutputStream#connect is synchronized so the write is guarded by a lock, but PipedOutputStream#write is not synchronized, so the read is racy.
PipedOutputStream out = new PipedOutputStream();
PipedInputStream in = new PipedInputStream(out) ...
PipedOutputStream#connect will be called by the thread with the PipedInputStream and write to the field PipedOutputStream.sink, and that field will be read in the other thread by methods like PipedOutputStream#write.
PipedOutputStream#connect is synchronized so the write is guarded by a lock, but PipedOutputStream#write is not synchronized, so the read is racy.
- relates to
-
JDK-4291372 PipedOutputStream.connect(PipedInputStream) contains race condition
-
- Open
-