Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8266857

PipedOutputStream.sink should be volatile

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 17
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b22

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cushon Liam Miller-Cushon
              Reporter:
              cushon Liam Miller-Cushon
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: