Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2264

Recover from or prohibit partial bson reads

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • bson-5.0.0
    • Affects Version/s: None
    • Component/s: BSON
    • None

      Currently there are various bson decoding functions that may advance the read pointer in the byte buffer but ultimately raise an exception and thus fail to produce output. When this happens the byte buffer ends up in an unusable state as the read pointer could be pointing in the middle of a data structure.

      Either the read methods need to track the starting position in the byte buffer and reinstate it if an error or exception occurs, or they need to mark the byte buffer unusable upon encountering an error/exception via a flag which would prevent further decoding attempts on such byte buffer.

      After some internal discussion, we decided it would be best to simply document the existing contract for the buffer objects. Even resetting the buffer's cursor is not always sufficient, since it won't let you reset to a specific position, and thus is not recoverable if an error occurs part-way through a parse. Better to just let the developer know that the buffers are not guaranteed to be reusable after a parse error.

            Assignee:
            jamis.buck@mongodb.com Jamis Buck
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: