You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This problem is relatively easy to reproduce. When Object Mapper (default) is trying to decode a serialized string (JSON) of an object containing a field that is a list of Int64 and when one of the number's absolute value is small (-103 in this case). The object mapper would throw exception:
2023-07-08 00:06:29 ERROR localhost 494264 DLPFP 0: UploadController.cpp:00678 trid=342343234 rqid=0 tenantid=2400 user='' Decoding error for: { "simhash" : [ -1374461674807444439, -103, 1803150389721624332, -292347449805 ]}, err: [oatpp::mongo::bson::Utils::readPrimitive()]: Error. Can't deserialize Int64 value. BSON document value type is expected to be Int64.
The condition I found for this error is that the int64 absolute value is small. In the test code, it works for testString2 where I changed the small value to a big one. Looks like when the value is between [-2147483648, 2147483648) ie. 2^31, the deserializer will give this error.
Code snippets:
class TestDto : public oatpp::DTO {
DTO_INIT(TestDto, DTO)
DTO_FIELD(List<Int64>, simhash);
};
oatpp::Object<TestDto> decodeTestDto(const std::string &line)
{
auto doc = bsoncxx::from_json(line);
auto view = doc.view();
auto bson = oatpp::String((const char *)view.data(), view.length());
return m_objectMapper.readFromString<oatpp::Object<TestDto>>(bson);
}
@lganzzzo or @BillyONeal , could you take a quick look at this issue? It's pretty straight-forward to reproduce it. Any number in [-2147483648, 2147483648) can't be deserialized to an Int64. Thanks.
This problem is relatively easy to reproduce. When Object Mapper (default) is trying to decode a serialized string (JSON) of an object containing a field that is a list of Int64 and when one of the number's absolute value is small (-103 in this case). The object mapper would throw exception:
2023-07-08 00:06:29 ERROR localhost 494264 DLPFP 0: UploadController.cpp:00678 trid=342343234 rqid=0 tenantid=2400 user='' Decoding error for: { "simhash" : [ -1374461674807444439, -103, 1803150389721624332, -292347449805 ]}, err: [oatpp::mongo::bson::Utils::readPrimitive()]: Error. Can't deserialize Int64 value. BSON document value type is expected to be Int64.
Sample string:
{ "simhash" : [ -1374461674807444439, -103, 1803150389721624332, -292347449805 ]}"
The condition I found for this error is that the int64 absolute value is small. In the test code, it works for testString2 where I changed the small value to a big one. Looks like when the value is between [-2147483648, 2147483648) ie. 2^31, the deserializer will give this error.
Code snippets:
Testing Code and sample string:
The text was updated successfully, but these errors were encountered: