[CXX-742] client::database() should raise an exception if client is unitialized Created: 24/Nov/15 Updated: 11/Jan/16 Resolved: 22/Dec/15 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | API |
| Affects Version/s: | 0.2.0 |
| Fix Version/s: | 3.0.0-rc0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Scott Deerwester | Assignee: | Tess Avitabile (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | C++11 Driver MongoDB 3.2 | ||||||||
| Description |
|
If the database method of the client class is called for a client that is not properly initialized, the call segfaults. A check should be added for this condition and the error should be handled gracefully. |
| Comments |
| Comment by Githook User [ 22/Dec/15 ] |
|
Author: {u'username': u'tessavitabile', u'name': u'Tess Avitabile', u'email': u'tess.avitabile@mongodb.com'}Message: |
| Comment by Tess Avitabile (Inactive) [ 21/Dec/15 ] |
| Comment by Tess Avitabile (Inactive) [ 17/Dec/15 ] |
|
Sounds good! |
| Comment by Andrew Morrow (Inactive) [ 17/Dec/15 ] |
|
By 'goes well', I mean put it up for review with the changes just to database, and if we agree on the approach extend it to the other types. |
| Comment by Andrew Morrow (Inactive) [ 17/Dec/15 ] |
|
Seems reasonable. Why don't you try it with mongocxx::database, and if it goes well, do the same for client and collection? |
| Comment by Tess Avitabile (Inactive) [ 17/Dec/15 ] |
|
acm, samantha.ritter: Do you think this should be done the way Andrew suggested, with the private accessor returning an impl pointer? |
| Comment by Andrew Morrow (Inactive) [ 30/Nov/15 ] |
|
So, this is one we should think about. Calling any method on a default constructed client, database, or collection is currently illegal. To detect that would require us to add a check to (almost) every method on those classes. Easiest way to do that might be to add a private accessor that returns the impl pointer, use that everywhere we access it, and add the check to the accessor. Or, just document that using default initialized versions of these classes is illegal. I get why this change was requested, because making the use of a default constructed one of these objects illegal is surprising. However, nobody would be surprised that using a moved-from one of these objects was surprising. The default constructors were added exactly to allow creating an empty client/database/collection that could later be assigned to, deferring the real initialization. |