summaryrefslogtreecommitdiff
path: root/src/mongo/db/write_concern_options.cpp
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2014-02-10 12:16:04 -0500
committerRandolph Tan <randolph@10gen.com>2014-02-13 10:22:22 -0500
commit78b5eeb13142f0d9bcb43e67848d5fec2f29366d (patch)
tree7e95858944e9384ecb4009a427790287d61872ac /src/mongo/db/write_concern_options.cpp
parentdb7b5a93e9bdfee1826a91b94a9f8b904be89813 (diff)
downloadmongo-78b5eeb13142f0d9bcb43e67848d5fec2f29366d.tar.gz
SERVER-12596 writeConcern {} and writeConcern {wtimeout: 1000} treated like {w: 0}
Diffstat (limited to 'src/mongo/db/write_concern_options.cpp')
-rw-r--r--src/mongo/db/write_concern_options.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mongo/db/write_concern_options.cpp b/src/mongo/db/write_concern_options.cpp
index 2658797e5e3..db18073a3ac 100644
--- a/src/mongo/db/write_concern_options.cpp
+++ b/src/mongo/db/write_concern_options.cpp
@@ -37,6 +37,9 @@ namespace mongo {
const BSONObj WriteConcernOptions::Unacknowledged(BSON("w" << W_NONE));
Status WriteConcernOptions::parse( const BSONObj& obj ) {
+ if ( obj.isEmpty() ) {
+ return Status( ErrorCodes::BadValue, "write concern object cannot be empty" );
+ }
bool j = obj["j"].trueValue();
bool fsync = obj["fsync"].trueValue();
@@ -61,6 +64,7 @@ namespace mongo {
else if ( e.eoo() ||
e.type() == jstNULL ||
e.type() == Undefined ) {
+ wNumNodes = 1;
}
else {
return Status( ErrorCodes::BadValue, "w has to be a number or a string" );