[CSHARP-4870] CreateCluster throws NullReferenceException when not setting LoggingSettings Created: 14/Dec/23  Updated: 18/Dec/23  Resolved: 15/Dec/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 2.23.0
Fix Version/s: 2.23.1

Type: Bug Priority: Major - P3
Reporter: Remco Ros Assignee: Boris Dogadov
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by CSHARP-4871 Client crashes when trying to initial... Closed
is duplicated by CSHARP-4868 ArgumentNullException in MongoClient ... Closed
Problem/Incident
is caused by CSHARP-4716 Log informational message client-side... Closed
Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed
Documentation Changes Summary:

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?


 Description   

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

-



 Comments   
Comment by PM Bot [ 14/Dec/23 ]

Hi remcoros@live.nl, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 21:49:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.