Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-19975

NIOConverter File to ByteBuffer conversion behavior is potentially non-deterministic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 4.0.2, 4.2.0
    • camel-core
    • None
    • Unknown

    Description

      Maybe a bit of an edge case, but the result of NIOConverter.toByteBuffer(File) can potentially vary depending on the size of the file used for conversion. It can be null or a ByteBuffer with partial or empty content.

      The converter does:

      byte[] buf = new byte[(int) file.length()];
      

      If file.length() > Integer.MAX_VALUE, then the cast from long to int can produce some unexpected results. E.g if the file size is Integer.MAX_VALUE + 1, then the result from the cast is -2147483648. If the file size is 4294967296 then the result from the cast is 0.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            jamesnetherton James Netherton
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: