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

(ch) Input/Output streams returned by Channels factory methods don't support concurrent read/write ops

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 19
    • None
    • core-libs
    • None
    • b05

      If someone has a SocketChannel sc then one way to obtain input/output streams is via the Socket adaptor, i.e. sc.socket().getXXXStream. Another way is with Channels.newXXXStream(sc) factory methods.

      A long standing limitation (that dates from the original JSR-51 and Java 1.4) is that the input/output streams returned by the Channels.newXXXStream methods must synchronize on the channel's blockingLock() to prevent the channel from being configured non-blocking. There is one "blocking lock" per SelectableChannel so problematic when the SelectableChannel is also a ByteChannel as it prevents a thread from writing while another is blocked in read (and vice versa).

      More background on this issue can be found in JDK-4509080. The input/output streams for the Socket adaptor had the same limitation prior to changes in JDK 13 and JDK-8222774. The issue with the streams returned by Channels.newXXXStream resurfaced recently as part of side discussion of JDK-8278268.

            alanb Alan Bateman
            alanb Alan Bateman
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: