Uploaded image for project: 'WildFly EJB HTTP Client'
  1. WildFly EJB HTTP Client
  2. WEJBHTTP-50

WildFlyClientOutputStream.flips unwritten buffer if invoked after write returns 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.1.5.Final, 1.0.25.Final
    • None
    • None

      At WildFlyClientOutputStream, the write listener can be invoked multiple times as expected for any write listener in XNIO architecture.

      However, if the listener is invoked and fails to write the buffer at this line, the listener returns without making any modifications to the buffer. When the listener is invoked again, the buffer is erroneously flipped, causing all the bytes that were already written, if any, to become the new bytes to write, and causing the remaining bytes to become ignored, as a flip does the following to the buffer:
      buffer[position=x,limit=y,capacity=n] -> buffer[position=0,limit=x,capacity=n] // notice that the bytes that have been already previously written are in the interval from index 0 to x, and the bytes that have to be written are in the interval from index x to y

      As a result, we can have a group of bytes written by mistake twice (from 0 to x, notice it could be zero bytes if x equals 0), while the second group of bytes (from index x to index y) is suppressed from the channel communication and will not be delivered to the server.

              flaviarnn Flavia Rainone
              flaviarnn Flavia Rainone
              Alessio Soldano, Brad Maxwell, Cheng Fang, Joerg Baesner, noswagger, Richard Opalka, Stefano Maestri, Ted Won, Tomasz Adamski
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: