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

Oid == operator overload: null comparison problem

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      The == overload in the Oid class is incorrect. In the case that one of the Oids in a comparison is null, an exception is thrown. The overload does not take into account the possibility that either reference is null.

      This is what the overload should look like:

      public static bool operator ==(Oid a, Oid b){

      // Return true if both are same instance or both are null
      if (System.Object.ReferenceEquals(a, b))

      { return true; }

      // Return false if only one instance is null
      if (((object)a == null) || ((object)b == null))

      { return false; }

      return a.Equals(b);
      }

      This is taken from the following MS site:

      http://msdn.microsoft.com/en-us/library/ms173147%28VS.80%29.aspx

            Assignee:
            sam Sam Corder
            Reporter:
            ant512 Antony Dzeryn
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: