Skip to content

[BUG] java.lang.ArrayIndexOutOfBoundsException: arraycopy: last destination index 6232 out of bounds for char[576] #3989

@Shui-Ze

Description

@Shui-Ze

问题描述

简要描述您碰到的问题。
fastjson正常, fastjson2字符串转对象报错: java.lang.ArrayIndexOutOfBoundsException: arraycopy: last destination index 6232 out of bounds for char[576]

环境信息

请填写以下信息:

  • JDK信息: [e.g.:openjdk version "21.0.9"]
  • 版本信息:[e.g.:Fastjson2 2.0.61]

重现步骤

如何操作可以重现该问题:
运行main方法

//可在此输入示例代码


import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

public class IssueDemo {

    public static void main(String[] args) {
        String inputJson;

        // [input.json](https://github.com/user-attachments/files/25176147/input.json)

        try {
            inputJson = FileUtils.readFileToString(new File("/tmp/input.json"));
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        JSONObject inputJsonObject = JSON.parseObject(inputJson);
        assert inputJsonObject.getInteger("enable") == 1;
    }
}

期待的正确结果

无报错

相关日志输出

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: arraycopy: last destination index 6232 out of bounds for char[576]
at java.base/java.lang.System.arraycopy(Native Method)
at com.alibaba.fastjson2.JSONReaderUTF16.readString(JSONReaderUTF16.java:3259)
at com.alibaba.fastjson2.JSONReader.readObject(JSONReader.java:3777)
at com.alibaba.fastjson2.JSONReader.read(JSONReader.java:3539)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:476)
at ps.pf.ebay.logic.cross.sell.IssueDemo.main(IssueDemo.java:23)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions