Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ObjectReader12中编码错误导致属性丢失问题 #893

Closed
saturneric opened this issue Nov 2, 2022 · 2 comments
Closed

ObjectReader12中编码错误导致属性丢失问题 #893

saturneric opened this issue Nov 2, 2022 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@saturneric
Copy link
Contributor

saturneric commented Nov 2, 2022

if (hashCode == hashCode11LCase) {
return fieldReader10;
}

这里出现了编码的错误,hashCode11LCase应该对应fieldReader11而不是fieldReader10。
这个会导致属性丢失,我这边有一段代码可以复现这个问题

        String json = "{\"nonce\": \"1667236815\", \"timestamp\": \"1667236845207\", \"vin\": \"XXXXXXXXXXXX\",  \"model\": \"A3\", \"sign\": \"b0a979d71f6bd54186fef5\", \"version\": \"1.0\", \"appid\": \"test\", \"productid\": \"1234\"}";

        JSONObject requestJson = JSONObject.parseObject(json);
        Assert.assertNotNull(requestJson);
        log.info(JSONObject.toJSONString(requestJson));

        RegisterRequest request = requestJson.to(RegisterRequest.class);
        log.info(JSONObject.toJSONString(request));

        Assert.assertNotNull(request.getVin());

这段测试代码中,最后一个assert会失败,因为vin这个属性丢失了。

@wenshao wenshao added this to the 2.0.18 milestone Nov 2, 2022
@wenshao wenshao added the bug Something isn't working label Nov 2, 2022
@saturneric
Copy link
Contributor Author

补充一下,RegisterRequest中恰好有12个属性。

@wenshao
Copy link
Member

wenshao commented Nov 6, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.18
问题已修复,请用新版本

@wenshao wenshao closed this as completed Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants