Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-206

ServletOutputStreamImpl.write is using byte length incorrectly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.0.2.Final
    • 1.0.0.Final
    • Servlet
    • None
    • Hide

      Create a servlet that uses the 3 argument variant of ServletOutputStream.write to write a byte array, specify a non 0 offset and number of bytes and observe that the number of bytes returned is less than expected with the missing number of bytes matching the specified offset.

      Show
      Create a servlet that uses the 3 argument variant of ServletOutputStream.write to write a byte array, specify a non 0 offset and number of bytes and observe that the number of bytes returned is less than expected with the missing number of bytes matching the specified offset.

      Code that previously worked correctly on JBoss 4 now returns the incorrect number of bytes. We have a servlet that uses the 3 argument version of output.write as follows:

      output.write(bytes, offset, length);

      According to the JavaDoc, 'length' specifies the number of bytes to write - however the bytes being returned seem to be length-offset which would suggest that undertow is treating 'length' as an end position. Changing our code so that 'length' includes the offset size fixes the issue but obviously this doesn't match the spec.

            sdouglas1@redhat.com Stuart Douglas
            rasto68_jira Rob Stone (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: