Skip to content

Commit 0c4797a

Browse files
Refs #22202. TMP: will it pass?
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
1 parent 5037af4 commit 0c4797a

2 files changed

Lines changed: 30 additions & 13 deletions

File tree

src/cpp/fastdds/xtypes/serializers/json/dynamic_data_json.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,12 +582,12 @@ ReturnCode_t json_serialize_enum_member(
582582
enum_type = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_desc->type())->resolve_alias_enclosed_type();
583583
}
584584

585-
if (nullptr == enum_type)
586-
{
587-
EPROSIMA_LOG_ERROR(XTYPES_UTILS,
588-
"Error encountered while serializing TK_ENUM member to JSON: null enum type.");
589-
return RETCODE_BAD_PARAMETER;
590-
}
585+
// if (nullptr == enum_type)
586+
// {
587+
// EPROSIMA_LOG_ERROR(XTYPES_UTILS,
588+
// "Error encountered while serializing TK_ENUM member to JSON: null enum type.");
589+
// return RETCODE_BAD_PARAMETER;
590+
// }
591591

592592
// Get value depending on the enclosing type
593593
assert(enum_type->get_kind() == TK_ENUM);
@@ -597,6 +597,12 @@ ReturnCode_t json_serialize_enum_member(
597597
auto enum_desc = enum_members.at(0)->get_descriptor();
598598
auto enum_member_type = enum_desc.type();
599599
auto enum_member_type_impl = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_member_type);
600+
if (nullptr == enum_member_type_impl)
601+
{
602+
EPROSIMA_LOG_ERROR(XTYPES_UTILS,
603+
"Error encountered while serializing TK_ENUM member to JSON: null enum member type.");
604+
return RETCODE_BAD_PARAMETER;
605+
}
600606
TypeKind enclosing_kind = enum_member_type_impl->get_kind();
601607
nlohmann::json j_value;
602608
if (TK_INT8 == enclosing_kind)

src/cpp/fastdds/xtypes/serializers/json/json_dynamic_data.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -677,17 +677,28 @@ ReturnCode_t json_deserialize_enum_member(
677677
enum_type = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_desc->type())->resolve_alias_enclosed_type();
678678
}
679679

680-
if (nullptr == enum_type)
680+
// if (nullptr == enum_type)
681+
// {
682+
// EPROSIMA_LOG_ERROR(XTYPES_UTILS,
683+
// "Error encountered while deserializing TK_ENUM member from JSON: null enum type.");
684+
// return RETCODE_BAD_PARAMETER;
685+
// }
686+
687+
// Get enclosing type kind to parse the value accordingly, and later user the appropriate setter
688+
assert(enum_type->get_kind() == TK_ENUM);
689+
// TypeKind enclosing_kind = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_type->get_all_members_by_index().at(
690+
// 0)->get_descriptor().type())->get_kind(); // Unfortunately DynamicDataImpl::get_enclosing_typekind is private
691+
auto enum_members = enum_type->get_all_members_by_index();
692+
auto enum_desc = enum_members.at(0)->get_descriptor();
693+
auto enum_member_type = enum_desc.type();
694+
auto enum_member_type_impl = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_member_type);
695+
if (nullptr == enum_member_type_impl)
681696
{
682697
EPROSIMA_LOG_ERROR(XTYPES_UTILS,
683-
"Error encountered while deserializing TK_ENUM member from JSON: null enum type.");
698+
"Error encountered while deserializing TK_ENUM member from JSON: null enum member type.");
684699
return RETCODE_BAD_PARAMETER;
685700
}
686-
687-
// Get enclosing type kind to parse the value accordingly, and later user the appropriate setter
688-
assert(enum_type->get_kind() == TK_ENUM);
689-
TypeKind enclosing_kind = traits<DynamicType>::narrow<DynamicTypeImpl>(enum_type->get_all_members_by_index().at(
690-
0)->get_descriptor().type())->get_kind(); // Unfortunately DynamicDataImpl::get_enclosing_typekind is private
701+
TypeKind enclosing_kind = enum_member_type_impl->get_kind();
691702

692703
if (DynamicDataJsonFormat::OMG == format)
693704
{

0 commit comments

Comments
 (0)