-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 2.23.0
-
Component/s: None
-
None
-
Fully Compatible
-
Not Needed
-
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
-
- is caused by
-
CSHARP-4716 Log informational message client-side based on detected environment (DocumentDB or CosmosDB)
- Closed
- is duplicated by
-
CSHARP-4871 Client crashes when trying to initializing the mongoclient when setting clusterconfigurator
- Closed
-
CSHARP-4868 ArgumentNullException in MongoClient constructor in 2.23.0
- Closed