[SERVER-74184] Support SerializationContext in constructors for IDL structs Created: 18/Feb/23  Updated: 29/Oct/23  Resolved: 16/Mar/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 6.3.0-rc1
Fix Version/s: 7.0.0-rc0

Type: Task Priority: Major - P3
Reporter: Hugh Tong (Inactive) Assignee: Hugh Tong (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-74284 Fix existing tests for command serial... Closed
Assigned Teams:
Serverless
Backwards Compatibility: Fully Compatible
Sprint: Server Serverless 2023-03-06, Server Serverless 2023-03-20
Participants:

 Description   

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).



 Comments   
Comment by Githook User [ 15/Mar/23 ]

Author:

{'name': 'Hugh Tong', 'email': 'hugh.tong@mongodb.com', 'username': 'cortrain'}

Message: SERVER-74184 Support SerializerFlags in constructors for IDL structs
Branch: master
https://github.com/mongodb/mongo/commit/289841d600f8319f9e20a0f4f10178705bdf38e8

Generated at Thu Feb 08 06:26:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.