Skip to content
New issue

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

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

Already on GitHub? # to your account

[BUG] JSONB 序列化特定的JSON是报数组溢出错误 #744

Closed
jimichan opened this issue Sep 8, 2022 · 5 comments
Closed

[BUG] JSONB 序列化特定的JSON是报数组溢出错误 #744

jimichan opened this issue Sep 8, 2022 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@jimichan
Copy link

jimichan commented Sep 8, 2022

问题描述

JSONB 序列化特定的JSON是报数组溢出错误,测试JOSN文件在
test.json.zip

环境信息

请填写以下信息:

  • OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB]
  • JDK信息: [e.g.:Openjdk 17]
  • 版本信息:[e.g.:Fastjson2 2.0.12]

重现步骤

如何操作可以重现该问题:

  1. 使用 JSONB.toBytes 方法
  2. 输入 附件中的test.json 数据
  3. 出现 错误
    val json = File("test.json").readText()

    val map = JSON.parseObject(json)

    val bytes = JSONB.toBytes(map)

期待的正确结果

别爆出异常

相关日志输出

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: arraycopy: last destination index 274141 out of bounds for byte[274140]
at java.base/java.lang.System.arraycopy(Native Method)
at com.alibaba.fastjson2.JSONWriterJSONB.writeString(JSONWriterJSONB.java:575)
at com.alibaba.fastjson2.writer.ObjectWriterImplMap.writeJSONB(ObjectWriterImplMap.java:257)
at com.alibaba.fastjson2.JSONB.toBytes(JSONB.java:793)
at TestKt.main(Test.kt:15)
at TestKt.main(Test.kt)

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

test.json.zip

@jimichan jimichan added the bug Something isn't working label Sep 8, 2022
@jimichan jimichan changed the title [BUG] [BUG] JSONB 序列化特定的JSON是报数组溢出错误 Sep 8, 2022
@wenshao
Copy link
Member

wenshao commented Sep 8, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.13-SNAPSHOT/
问题已经修复,请用2.0.13-SNAPSHOT版本帮忙验证,2.0.13版本预计9月12日发布

@wenshao wenshao added this to the 2.0.13 milestone Sep 8, 2022
wenshao added a commit that referenced this issue Sep 8, 2022
@jimichan
Copy link
Author

jimichan commented Sep 9, 2022

测试了 fastjson2-2.0.13-20220907.220828-61.jar
应该没有被修复

@wenshao
Copy link
Member

wenshao commented Sep 9, 2022

我本地测试已经是修复,能更新到fastjson2-2.0.13-20220909.000016-65.jar 再帮忙验证下么?

如果还是报错,提供下更新后错误堆栈信息

@wenshao
Copy link
Member

wenshao commented Sep 10, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.13
2.0.13版本已经发布,请用帮忙用新版本验证

@wenshao wenshao modified the milestones: 2.0.13, 2.0.14 Sep 10, 2022
@jimichan
Copy link
Author

可以了👍

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants