We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
想要将一个大对象转换为JSON字符串,转换过程中抛出ArrayIndexOutOfBoundsException数组越界异常,debug截图如下:
进入该方法时,this.off == 27637,计算minCapacity判断是否扩容时,只增加了10个容量,此时27637 + 10 = 27647小于chars.length = 27648,判断为不需要扩容。在执行后续步骤时,实际上会取到11个偏移量,由于chars数组的最大下标为27647,因此造成数组越界。
this.off == 27637
minCapacity
27637 + 10 = 27647
chars.length = 27648
chars
27647
请填写以下信息:
示例代码如下(内部数据,无法提供):
JSON.config(JSONWriter.Feature.LargeObject, true); String jsonString = JSONObject.toJSONString(dataBasePO, SerializerFeature.DisableCircularReferenceDetect);
期望能够正确将对象转换为JSON字符串,不要抛出异常。或者通过某些配置能够实现正确转换
com.alibaba.fastjson.JSONException: toJSONString error at com.alibaba.fastjson.JSON.toJSONString(JSON.java:1578) at com.uxsino.uxsync.core.infrastructure.repository.impl.MetaDataInFileRepositoryImpl.save(MetaDataInFileRepositoryImpl.java:62) at com.uxsino.uxsync.core.domain.service.MetaDataDomainService.save(MetaDataDomainService.java:48) at com.uxsino.uxsync.core.app.service.MetaDataAppService.refreshAll(MetaDataAppService.java:51) at com.uxsino.db.uxsync.metadata.domain.service.MetaDataDomainService.lambda$submitTask$0(MetaDataDomainService.java:151) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 27648 out of bounds for length 27648 at com.alibaba.fastjson2.JSONWriterUTF16.writeName8Raw(JSONWriterUTF16.java:1719) at com.alibaba.fastjson2.writer.OWG_7_18_ColumnPO.write(Unknown Source) at com.alibaba.fastjson2.writer.FieldWriterList.writeListValue(FieldWriterList.java:218) at com.alibaba.fastjson2.writer.OWG_6_15_DataBasePO.write(Unknown Source) at com.alibaba.fastjson.JSON.toJSONString(JSON.java:1570) ... 10 common frames omitted
暂无其它信息提供
The text was updated successfully, but these errors were encountered:
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.49-SNAPSHOT/ 问题已经修复,请帮忙用2.0.49-SNAPSHOT版本验证,2.0.49版本预计在本周末(4月14日)前发布
Sorry, something went wrong.
fix writeName8Raw ArrayIndexOutOfBoundsException error, for issue #2419
1aef6dc
#2433
d702e91
使用 fastjson2-2.0.49-20240412.055049-9.jar 包替换验证,能够成功转换JSON字符串。谢谢 @wenshao
https://github.com/alibaba/fastjson2/releases/tag/2.0.49 请用新版本
No branches or pull requests
问题描述
想要将一个大对象转换为JSON字符串,转换过程中抛出ArrayIndexOutOfBoundsException数组越界异常,debug截图如下:
进入该方法时,
this.off == 27637
,计算minCapacity
判断是否扩容时,只增加了10个容量,此时27637 + 10 = 27647
小于chars.length = 27648
,判断为不需要扩容。在执行后续步骤时,实际上会取到11个偏移量,由于chars
数组的最大下标为27647
,因此造成数组越界。环境信息
请填写以下信息:
重现步骤
示例代码如下(内部数据,无法提供):
期待的正确结果
期望能够正确将对象转换为JSON字符串,不要抛出异常。或者通过某些配置能够实现正确转换
相关日志输出
附加信息
暂无其它信息提供
The text was updated successfully, but these errors were encountered: