diff options
author | Benety Goh <benety@mongodb.com> | 2017-04-12 16:33:01 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2017-04-17 12:06:58 -0400 |
commit | 0a51d1eb89d4a915ff3ffd9584fdfc99a633d94b (patch) | |
tree | 6f29460a68cee902da64e91f31ecfc747d33d540 /src/mongo | |
parent | d44e25dde3c61d729b8e97a2118e15ec80683c83 (diff) | |
download | mongo-0a51d1eb89d4a915ff3ffd9584fdfc99a633d94b.tar.gz |
SERVER-28211 UUID::parse(BSONElement) returns InvalidUUID instead of UnknownError on error
Diffstat (limited to 'src/mongo')
-rw-r--r-- | src/mongo/bson/bsonelement.h | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/rollback_fix_up_info_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/util/uuid_test.cpp | 12 |
3 files changed, 10 insertions, 8 deletions
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h index 3120907b589..2d815383b2c 100644 --- a/src/mongo/bson/bsonelement.h +++ b/src/mongo/bson/bsonelement.h @@ -584,7 +584,9 @@ public: const char* data = nullptr; if (type() == BinData && binDataType() == BinDataType::newUUID) data = binData(len); - uassert(00000, "uuid must be a 16-byte binary field with UUID (4) subtype", len == 16); + uassert(ErrorCodes::InvalidUUID, + "uuid must be a 16-byte binary field with UUID (4) subtype", + len == 16); std::array<unsigned char, 16> result; memcpy(&result, data, len); return result; diff --git a/src/mongo/db/repl/rollback_fix_up_info_test.cpp b/src/mongo/db/repl/rollback_fix_up_info_test.cpp index 1d8ba52237d..3ca7f780dc6 100644 --- a/src/mongo/db/repl/rollback_fix_up_info_test.cpp +++ b/src/mongo/db/repl/rollback_fix_up_info_test.cpp @@ -332,7 +332,7 @@ TEST_F( << false)); auto collectionUuid = unittest::assertGet(UUID::parse(operation["ui"])); NamespaceString sourceNss(operation["o"].Obj().firstElement().String()); - ASSERT_EQUALS(ErrorCodes::UnknownError, UUID::parse(operation["o"].Obj()["dropTarget"])); + ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse(operation["o"].Obj()["dropTarget"])); ASSERT_TRUE(OplogEntry(operation).isCommand()); diff --git a/src/mongo/util/uuid_test.cpp b/src/mongo/util/uuid_test.cpp index 6b9ab3b295a..e321f840e5e 100644 --- a/src/mongo/util/uuid_test.cpp +++ b/src/mongo/util/uuid_test.cpp @@ -136,9 +136,9 @@ TEST(UUIDTest, toAndFromString) { ASSERT_NOT_EQUALS(UUID::parse(s4).getValue(), UUID::parse(s5).getValue()); // UUIDs cannot be constructed from invalid strings - ASSERT_NOT_OK(UUID::parse("00000000000040008000000000000000")); - ASSERT_NOT_OK(UUID::parse("d-d-d-dddddeeee4fffaaaa-bbbbbbbbbbbb")); - ASSERT_NOT_OK(UUID::parse("samsamsa-sams-4sam-8sam-samsamsamsam")); + ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse("00000000000040008000000000000000")); + ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse("d-d-d-dddddeeee4fffaaaa-bbbbbbbbbbbb")); + ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse("samsamsa-sams-4sam-8sam-samsamsamsam")); } TEST(UUIDTest, toAndFromBSONTest) { @@ -162,12 +162,12 @@ TEST(UUIDTest, toAndFromBSONTest) { // UUIDs cannot be constructed from invalid BSON elements auto bson2 = BSON("uuid" << "sam"); - ASSERT_NOT_OK(UUID::parse(bson2.getField("uuid"))); + ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse(bson2.getField("uuid"))); auto bson3 = BSON("uuid" << "dddddddd-eeee-4fff-aaaa-bbbbbbbbbbbb"); - ASSERT_NOT_OK(UUID::parse(bson3.getField("uuid"))); + ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse(bson3.getField("uuid"))); auto bson4 = BSON("uuid" << 14); - ASSERT_NOT_OK(UUID::parse(bson4.getField("uuid"))); + ASSERT_EQUALS(ErrorCodes::InvalidUUID, UUID::parse(bson4.getField("uuid"))); } } // namespace |