File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -486,7 +486,12 @@ void ToProto(
486
486
{
487
487
serializedMap->clear ();
488
488
for (const auto & [key, value] : originalMap) {
489
- serializedMap->insert (std::pair (ToProto<TSerializedKey>(key), ToProto<TSerializedValue>(value)));
489
+ auto [_, inserted] = serializedMap->insert (std::pair (ToProto<TSerializedKey>(key), ToProto<TSerializedValue>(value)));
490
+ if (!inserted) {
491
+ THROW_ERROR_EXCEPTION (" Found duplicate key during protobuf map serialization" )
492
+ << TErrorAttribute (" key" , key)
493
+ << TErrorAttribute (" serialized_key" , ToProto<TSerializedKey>(key));
494
+ }
490
495
}
491
496
}
492
497
@@ -533,7 +538,11 @@ void FromProto(
533
538
{
534
539
originalMap->clear ();
535
540
for (const auto & [serializedKey, serializedValue] : serializedMap) {
536
- EmplaceOrCrash (*originalMap, FromProto<TKey>(serializedKey), FromProto<TValue>(serializedValue));
541
+ auto [_, inserted] = originalMap->emplace (FromProto<TKey>(serializedKey), FromProto<TValue>(serializedValue));
542
+ if (!inserted) {
543
+ THROW_ERROR_EXCEPTION (" Found duplicate key during protobuf map deserialization" )
544
+ << TErrorAttribute (" key" , FromProto<TKey>(serializedKey));
545
+ }
537
546
}
538
547
}
539
548
You can’t perform that action at this time.
0 commit comments