[SERVER-18738] FindAndModifyCommand::run can create an invalid StatusWith Created: 29/May/15  Updated: 19/Sep/15  Resolved: 29/May/15

Status: Closed
Project: Core Server
Component/s: Internal Code, Querying
Affects Version/s: None
Fix Version/s: 3.1.4

Type: Bug Priority: Major - P3
Reporter: Adam Midvidy Assignee: Adam Midvidy
Resolution: Done Votes: 0
Labels: UT
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-18007 StatusWith should work with non-defau... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Pull https://github.com/amidvidy/mongo/tree/SERVER-18007-optional and run any of find_and_modify

{"", 2, 3, 4}

.js

Sprint: Platform 4 06/05/15
Participants:

 Description   

StatusWith<WriteConcernOptions> wcResult = extractWriteConcern(cmdObj);
... lots of lines of code...
WriteConcernResult res;
wcResult = waitForWriteConcern(
                    txn,
                    repl::ReplClientInfo::forClient(txn->getClient()).getLastOp(),
                    &res);
appendCommandWCStatus(result, wcResult.getStatus());

Note that waitForWriteConcern returns a Status, not a StatusWith. If it succeeds, Status::OK() is assigned to wcResult which creates an invalid StatusWith. An engaged StatusWith<T> (i.e. a StatusWith<T> s, such that s.isOK() == true) can only be created by assigning a T - assigning Status::OK() does not actually initialize the value.



 Comments   
Comment by Githook User [ 29/May/15 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: SERVER-18738 avoid creating an invalid StatusWith in FindAndModifyCommand::run()
Branch: master
https://github.com/mongodb/mongo/commit/981d2344da6187d51b253557ba268c835fedcfe1

Generated at Thu Feb 08 03:48:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.