Skip to content

Commit

Permalink
Revert incorrect fix from https://review.opencontrail.org/#/c/35856/
Browse files Browse the repository at this point in the history
There were two issues with the fix made before.

1. All spaces inside link attribute was erased, which is clearly incorrect.
2. JSON supports NULL already. We need to check for null and then set
   the link attribute as an empty object if attr data turns out to be null.

Change-Id: I8cdf876196a709571ee4b763c19af7a0d81e85f8
Closes-Bug: 1773197
  • Loading branch information
ananth-at-camphor-networks committed Jul 24, 2018
1 parent 0667e01 commit 78c037c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions config-client-mgr/config_cass2json_adapter.cc
Expand Up @@ -160,18 +160,18 @@ void ConfigCass2JsonAdapter::AddOneEntry(Value *jsonObject,
IsLinkWithAttr(obj_type, ref_type);
if (link_with_attr) {
Document ref_document(&a);
string c_value = c.value;
c_value.erase(remove(c_value.begin(), c_value.end(), ' '),
c_value.end());
if (c_value == "{\"attr\":null}")
c_value = "{\"attr\":{}}";
ref_document.Parse<0>(c_value.c_str());
ref_document.Parse<0>(c.value.c_str());
CONFIG_PARSE_ASSERT(ReferenceLinkAttributes,
!ref_document.HasParseError());
CONFIG_PARSE_ASSERT(ReferenceLinkAttributes,
ref_document.HasMember("attr"));
Value &attr_value = ref_document["attr"];
v.AddMember("attr", attr_value, a);
if (!attr_value.IsNull()) {
v.AddMember("attr", attr_value, a);
} else {
Value vm;
v.AddMember("attr", vm.SetObject(), a);
}
} else {
Value vm;
v.AddMember("attr", vm.SetObject(), a);
Expand Down

0 comments on commit 78c037c

Please sign in to comment.