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] JSONValidator.validate() #2566

Open
Cooper-Zhong opened this issue May 12, 2024 · 2 comments
Open

[BUG] JSONValidator.validate() #2566

Cooper-Zhong opened this issue May 12, 2024 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@Cooper-Zhong
Copy link

问题描述

fastjson2中JSON.isValid无异常,JSONValidator.from().validate()报错

环境信息

  • OS信息: [MacOS 12.7.4 M1 Pro 16 GB]
  • JDK信息: [Openjdk 17.0.6]
  • 版本信息:[Fastjson2 2.0.50]

重现步骤

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONValidator;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class MutatedIssue3343_200 {
    
    @Test
    public void test() {
        // Testing with incorrect JSON syntax
        assertFalse(
                JSON.isValid("{\"name\":\"999}")
                        );
        assertFalse(
                JSONValidator.from("{\"name\":\"999}")
                        .validate());
    }
}

相关日志输出

java.lang.ArrayIndexOutOfBoundsException: Index 13 out of bounds for length 13
at com.alibaba.fastjson2.JSONReaderUTF8.skipValue(JSONReaderUTF8.java:4874)
at com.alibaba.fastjson2.JSONReaderUTF8.skipValue(JSONReaderUTF8.java:4904)
at com.alibaba.fastjson2.JSONValidator.validate(JSONValidator.java:36)
at MutatedIssue3343_200.test(MutatedIssue3343_200.java:20)

@Cooper-Zhong Cooper-Zhong added the bug Something isn't working label May 12, 2024
@wenshao wenshao added this to the 2.0.51 milestone May 12, 2024
@wenshao wenshao added the fixed label May 12, 2024
@wenshao
Copy link
Member

wenshao commented May 12, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.51-SNAPSHOT/
问题已修复,请帮忙用2.0.51-SNAPSHOT版本验证下

@Cooper-Zhong
Copy link
Author

验证无问题,辛苦wenshao

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