Details
-
Bug
-
Resolution: Won't Fix
-
Major - P3
-
None
-
None
-
None
-
Sharding
-
Fully Compatible
-
ALL
Description
FindAndModify upserts return "null" in the "value" field, which ping() inspects to determine whether the command was successful or not. So the first ping() call always fails, which appears to do no harm because the use case only logs a warning and continues to the next ping(), which succeeds.
The unit test is incorrect and creates a return BSONObj with a filled out "value" field, so the testing passes anyway. Seems like you can just add
request.setShouldReturnNew(true);
in ping(), and the first ping won't be interpreted as failed because it has a non-null "value" field. The helper function _extractFindAndModifyNewObj is a little ugly, though, because it's limited to null meaning failure, so the other option is to refactor it to parse some more details from the BSONObj it inspects.
Unit tests around the functions using _extractFindAndModifyNewObj should be checked for correctness afterwards.