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

CreateCluster throws NullReferenceException when not setting LoggingSettings

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.23.1
    • Affects Version/s: 2.23.0
    • Component/s: None
    • None
    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Summary

      CSHARP-4716 introduces a NullReferenceException when not setting 'LoggingSettings' on a MongoClient.

      The cause of this is that on line #131 in ClusterFactory.cs 'loggerFactory.CreateLogger' is used. loggerFactory can be null, so that throws a NRE.

      The pattern used in other places is to use MongoDB Drivers' own extension method: 'loggerFactory.CreateEventLogger', the latter has proper null checks for when 'loggerFactory' is null.

      Proposed solution: change that line to use 'loggerFactory.CreateEventLogger(..)'

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      MongoDB.Driver 2.23

      How to Reproduce

      Use a 'MongoClient' instance without specifying LoggingSettings.

      Additional Background

      -

            Assignee:
            boris.dogadov@mongodb.com Boris Dogadov
            Reporter:
            remcoros@live.nl Remco Ros
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: