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

[BUG] java.lang.ArrayIndexOutOfBoundsException: 1 #1860

Closed
catgptjourney opened this issue Sep 13, 2023 · 3 comments
Closed

[BUG] java.lang.ArrayIndexOutOfBoundsException: 1 #1860

catgptjourney opened this issue Sep 13, 2023 · 3 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@catgptjourney
Copy link

catgptjourney commented Sep 13, 2023

问题描述

简要描述您碰到的问题。
特殊字符转对象报下标越界 ArrayIndexOutOfBoundsException: 1

环境信息

  • OS信息:windows 11、centos7
  • JDK信息:Openjdk 1.8
  • 版本信息:Fastjson2 2.0.40

重现步骤

// 其他特殊字符也可以

package com.test.soft.warn.service;

import com.alibaba.fastjson2.JSON;

public class JsonArrayIndexOutDemo {

    public static void main(String[] args) {
        String json = "+";
        Object object = JSON.parse(json);
        System.out.println(JSON.toJSONString(object));
    }

}

期待的正确结果

代码执行正常通过

相关日志输出

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at com.alibaba.fastjson2.JSONReaderUTF16.readNumber0(JSONReaderUTF16.java:4591)
at com.alibaba.fastjson2.JSONReader.readNumber(JSONReader.java:1057)
at com.alibaba.fastjson2.reader.ObjectReaderImplObject.readObject(ObjectReaderImplObject.java:277)
at com.alibaba.fastjson2.JSON.parse(JSON.java:79)
at com.test.soft.warn.service.JsonArrayIndexOutDemo.main(JsonArrayIndexOutDemo.java:19)

@catgptjourney catgptjourney added the bug Something isn't working label Sep 13, 2023
@a1batr0ss
Copy link
Contributor

期望是输出什么呢?

@wenshao wenshao added this to the 2.0.41 milestone Sep 17, 2023
@wenshao wenshao added the fixed label Sep 17, 2023
@catgptjourney
Copy link
Author

期望是输出什么呢?

编译正常通过

@wenshao
Copy link
Member

wenshao commented Oct 6, 2023

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

@wenshao wenshao closed this as completed Oct 6, 2023
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

3 participants