[CSHARP-881] MongoServer.BuildInfo always null at start, magically populates later Created: 20/Dec/13 Updated: 20/Mar/14 Resolved: 23/Dec/13 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.8.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Andrew Ryder (Inactive) | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The following code snippet illustrates curious behaviour;
Example output of running the code;
If .BuildInfo is queried as the first order of business on a new server connection, then it appears to always yield null. After some other, possibly unrelated A value of null for BuildInfo on a valid connection is unexpected and should be documented if intended. Assuming that behaviour is correct, the library now lacks a signal to indicate when the member has transitioned to a valid state. Which in turn requires polling or knowledge of the implementation to be able to make use of it. In practice, it is not clear how to make robust use of this member. |
| Comments |
| Comment by Craig Wilson [ 23/Dec/13 ] |
|
This behavior will not be changed. |
| Comment by Craig Wilson [ 20/Dec/13 ] |
|
BuildInfo is populated after the server has connected. When you are first testing it, you haven't connected to the database yet. After you run a command, query, update, etc..., you will have connected to the database and this property will be populated. So, to make this more robust, simply do a srv.Connect() before testing the property. In addition, as this property is hanging off of MongoServer (which does not correlate to a specific server, but rather to a group or servers), it is not representative that you could actually be running a mixed version cluster. As such, it would be better to use buildInfos = srv.Instances.Select(x => x.BuildInfo); This will provide you the build info for each instance in the cluster. |