Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-547

Use of $csharpnull when serializing a BsonNull whose value is C# null halts replication (and in 2.2 the secondaries crash)

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.6
    • Affects Version/s: 1.5
    • Component/s: None
    • None
    • Minor Change

      The C# driver uses

      { $csharpnull : true }

      to represent a BsonNull property whose value is C# null. For example:

      public class C
      {
          public BsonNull a;
          public BsonNull b;
      }
      
      var c = new C { a = BsonNull.Value, b = null };
      Console.WriteLine(c.ToJson());
      

      results in:

      { "a" : null, "b" : { "$csharpnull" : true } }
      

      The C# driver needs to use some other representation for BsonNull values of C# null because this representation either causes replication to halt (prior to server 2.2) or the secondaries to crash (in server 2.2 rc0 and rc1).

      This is also a server bug, in the sense that no value that a client driver provides should be allowed to halt replication or crash secondaries. If the server considers this representation to be invalid then it should have been rejected outright by the primary.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: