summaryrefslogtreecommitdiff
path: root/src/mongo/rpc
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-06-22 19:35:59 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-06-27 14:33:09 -0400
commite7a75ec01e4e3683cc6b83e3bbc0f4c4b05168dc (patch)
treeb52326011cd57ac455f498c8f5d68c7a4fbea640 /src/mongo/rpc
parent0fdc2e40994c930a97aa213fa990423616bc5268 (diff)
downloadmongo-e7a75ec01e4e3683cc6b83e3bbc0f4c4b05168dc.tar.gz
SERVER-35691 Cleanup StaleConfigInfo serialization
Diffstat (limited to 'src/mongo/rpc')
-rw-r--r--src/mongo/rpc/legacy_reply_builder.cpp6
-rw-r--r--src/mongo/rpc/reply_builder_interface.cpp8
2 files changed, 6 insertions, 8 deletions
diff --git a/src/mongo/rpc/legacy_reply_builder.cpp b/src/mongo/rpc/legacy_reply_builder.cpp
index c2edc42b1cb..21e18cde76a 100644
--- a/src/mongo/rpc/legacy_reply_builder.cpp
+++ b/src/mongo/rpc/legacy_reply_builder.cpp
@@ -57,7 +57,6 @@ LegacyReplyBuilder& LegacyReplyBuilder::setCommandReply(Status nonOKStatus,
invariant(_state == State::kCommandReply);
if (nonOKStatus == ErrorCodes::StaleConfig) {
_staleConfigError = true;
- auto scex = nonOKStatus.extraInfo<StaleConfigInfo>();
// Need to use the special $err format for StaleConfig errors to be backwards
// compatible.
@@ -66,9 +65,8 @@ LegacyReplyBuilder& LegacyReplyBuilder::setCommandReply(Status nonOKStatus,
// $err must be the first field in object.
err.append("$err", nonOKStatus.reason());
err.append("code", nonOKStatus.code());
- if (scex) {
- scex->serialize(&err);
- }
+ auto const scex = nonOKStatus.extraInfo<StaleConfigInfo>();
+ scex->serialize(&err);
err.appendElements(extraErrorInfo);
setRawCommandReply(err.done());
} else {
diff --git a/src/mongo/rpc/reply_builder_interface.cpp b/src/mongo/rpc/reply_builder_interface.cpp
index 8a4460d7247..99d580bb279 100644
--- a/src/mongo/rpc/reply_builder_interface.cpp
+++ b/src/mongo/rpc/reply_builder_interface.cpp
@@ -37,15 +37,14 @@
namespace mongo {
namespace rpc {
-
namespace {
+
const char kOKField[] = "ok";
const char kCodeField[] = "code";
const char kCodeNameField[] = "codeName";
const char kErrorField[] = "errmsg";
-// similar to appendCommandStatusNoThrow (duplicating logic here to avoid cyclic library
-// dependency)
+// Similar to appendCommandStatusNoThrow (duplicating logic here to avoid cyclic library dependency)
BSONObj augmentReplyWithStatus(const Status& status, BSONObj reply) {
auto okField = reply.getField(kOKField);
if (!okField.eoo() && okField.trueValue()) {
@@ -75,7 +74,8 @@ BSONObj augmentReplyWithStatus(const Status& status, BSONObj reply) {
return bob.obj();
}
-}
+
+} // namespace
ReplyBuilderInterface& ReplyBuilderInterface::setCommandReply(StatusWith<BSONObj> commandReply) {
auto reply = commandReply.isOK() ? std::move(commandReply.getValue()) : BSONObj();