Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2125

BSONEncoder.encode output cannot be processed by BSONDecoder.decode

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 3.2.2
    • BSON
    • None

    Description

      Byte array received from client is decoded into a BSONObject using BSONDecoder. Byte array received follows:

      [42, 0, 0, 0, 2, 121, 111, 117, 0, 16, 0, 0, 0, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 53, 53, 52, 56, 55, 0, 1, 111, 107, 0, 0, 0, 0, 0, 0, 0, -16, 63, 0, 5, 0, 0, 0, 0]

      BSONObject is parsed and then encoded into a byte array using BSONEncoder. Byte array produced follows:

      [42, 0, 0, 0, 2, 121, 111, 117, 0, 16, 0, 0, 0, 49, 50, 55, 46, 48, 46, 48, 46, 49, 58, 53, 53, 52, 56, 55, 0, 1, 111, 107, 0, 0, 0, 0, 0, 0, 0, -16, 63, 0]

      The array generated by BSONEncoder appears to be missing an integer and a null character at the end of the array. Trying to decode the output of BSONEncoder using BSONDecoder results in an exception being thrown.

      It seems the expected outcome if no properties of the deserialized BSONObject are altered in that the output of BSONEncoder would be the same as the input to BSONDecoder.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rhoulihan Rick Houlihan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: