BSONEncoder.encode output cannot be processed by BSONDecoder.decode

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 3.2.2
    • Component/s: BSON
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Unassigned
            Reporter:
            Rick Houlihan
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: