Uploaded image for project: 'XNIO'
  1. XNIO
  2. XNIO-185

IoUtils.transfer(..) should only compact ByteBuffer if not all was transferred

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.0.8.GA, 3.1.0.Beta8
    • None
    • api
    • None

      IoUtils.transfer(..) does call ByteBuffer.compact() even if all of the data was transferred which is a problem for some Sink/Source implementations.

      In undertow we "adjust" the count that needs to get transfered before try to call transfer on the underlying channel. This is done because we need to limit the count of data that can be transfer from/to the channel. The problem here is now that the underlying channel use the IoUtils.transfer(..) method todo the actual transfer, which in fact transfer all the data. Now we return the actual transfered count to the caller which may be less to what was passed in. To full-fill the contract he end up checking if the used ByteBuffer has anything remaining. Which will in fact the complete capacity as compact() was called in the IoUtils.transfer(..) method even if all was transfered without a problem

            dlloyd@redhat.com David Lloyd
            normanmaurer Norman Maurer (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: