Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-74184

Support SerializationContext in constructors for IDL structs

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.0.0-rc0
    • Affects Version/s: 6.3.0-rc1
    • Component/s: None
    • Labels:
      None
    • Serverless
    • Fully Compatible
    • Server Serverless 2023-03-06, Server Serverless 2023-03-20

      While we can pass SerializationContext via the IDLContextParser when constructing structs via their parseProtected() calls, this is not the only way these structs are constructed.  In some cases, we call the parameterized constructors directly, which builds an unpopulated structure.  We still need to set the local SerializationContext held in the nested structures at all levels, which is set by the top-level enclosing class, and this needs to be done via the intializer lists.

      The flags should be set in the following priority order:

      1. Overriden by a valid set of SerializationContext being passed in
      2. Via the top-level enclosing class (as determined by the IDL configuration)
      3. Default if not a top-level enclosing class

      Case 1 will allow us to both override when explicitly passing flags in in our manual calls, as well as for nested structures to prioritize flags being passed in by their enclosing class.

      The above priority list applies to setting the local SerializationContext var, but because the state of these flags will be passed to nestesd structs, we to need to first set the local copy of SerializationContext before any nested structs, which means reordering the flags both in the initializer list and in the declaration.

      One thing to note is that we can't guarantee the flags exist at all levels without calling parse() because some of the nested structures are constructed manually by the callers, especially those that can't be determined at compile time (such as containerized objetcs).  In these cases, the responsibility of setting the flags remains with the caller, otherwise case 3 applies (and may be incorrect).

            Assignee:
            hugh.tong@mongodb.com Hugh Tong (Inactive)
            Reporter:
            hugh.tong@mongodb.com Hugh Tong (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: