Fix serialization and deserialization for ProvideServiceRequest in Gateway - #947
Conversation
| * std::string. | ||
| */ | ||
| template <> | ||
| inline score::Result<uint32_t> Deserialize<score::mw::com::impl::EventInfo>( |
There was a problem hiding this comment.
Specializing for this high-level type is probably too coarse.
I would expect that EventInfo falls into https://github.com/NemanjaTrifunovicRTRK/communication/blob/4bad624b0978207811515b9bdf449a7de8bd6622/score/mw/com/gateway/transport_layer/sample/messages/serialization.h#L394
This would mean you only need to provide Deserialize specializations for the internal non-trivially-copyable types.
Same pattern applies for Serialize(). Can you please check whether you can trim the fix into that direction?
There was a problem hiding this comment.
Deserialization of score::mw::com::impl::EventInfo fell into https://github.com/NemanjaTrifunovicRTRK/communication/blob/4bad624b0978207811515b9bdf449a7de8bd6622/score/mw/com/gateway/transport_layer/sample/messages/serialization.h#L348.
There was a problem hiding this comment.
In that case I think we need to sharpen https://github.com/NemanjaTrifunovicRTRK/communication/blob/4bad624b0978207811515b9bdf449a7de8bd6622/score/mw/com/gateway/transport_layer/sample/messages/serialization.h#L75 to also exclude std::string_views. Once that is done, you should have the expected behavior I outlined above.
There was a problem hiding this comment.
Please check score/mw/com/gateway/transport_layer/sample/messages/serialization.h again.
I changed the implementation to not specialize EventInfo type.
72eefe5 to
bf6e433
Compare
bf6e433 to
0b59f41
Compare
0b59f41 to
b1a68ee
Compare
The problem was with the deserialization of the field of type
score::mw::com::impl::EventInfoand itsstd::string_viewfield name:std::string_view is essentially a pointer into a string, so its (de)serialization requires the string's value to be copied, not just the pointer.
Implementation extended:
score/mw/com/gateway/transport_layer/sample/messages/BUILDscore/mw/com/gateway/transport_layer/sample/messages/serialization.hUnit tests extended:
score/mw/com/gateway/transport_layer/sample/messages/serialization.hIssue #387