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

(ch) Writer created by Channels::newWriter may lose data

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 22
    • 8, 11, 17, 21
    • core-libs
    • b21
    • Verified

    Description

      Spotted during code review; no known impact.

      StreamEncoder.writeBytes assumes (and asserts) that all bytes will be written to the target channel in a single invocation of write. If a channel only consumes a part of the provided ByteBuffer, any excess is lost.

      The attached test creates a writer on a channel that only consumes one byte at a time from the passed ByteBuffer. It should eventually consume all characters. Instead it either loses characters, or asserts if system assertions are enabled.

      Attachments

        Issue Links

          Activity

            People

              bpb Brian Burkhalter
              djelinski Daniel Jelinski
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: