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

byte[] 反序列化出错 #2464

Closed
tsingherd opened this issue May 31, 2019 · 0 comments
Closed

byte[] 反序列化出错 #2464

tsingherd opened this issue May 31, 2019 · 0 comments

Comments

@tsingherd
Copy link

tsingherd commented May 31, 2019

@Test
    public void test1(){
        String json = "[\"Mjg4NDd8MXxjb20uY2Fpbmlhby5pc2ltdS5xLndvcmtmbG93LmNvbGxlY3Quc2NoZWR1bGUuaW1wbC5UYXNrU3RvcENvbGxlY3RDYWxsQmFja0hhbmRsZXJJbXBsfDB8\",1]";
        Object result =  JSON.parseArray(json,new Class[]{byte[].class,Integer.class});
        assert null !=  result;
    }
    @Test
    public void test2(){
        String json = "[1,\"Mjg4NDd8MXxjb20uY2Fpbmlhby5pc2ltdS5xLndvcmtmbG93LmNvbGxlY3Quc2NoZWR1bGUuaW1wbC5UYXNrU3RvcENvbGxlY3RDYWxsQmFja0hhbmRsZXJJbXBsfDB8\"]";
        Object result =  JSON.parseArray(json,new Class[]{Integer.class,byte[].class});
        assert null !=  result;
    }

如上,有两个测试用例,test1和test2唯一的区别就是json里面数组两个元素调换了位置,结果test1可以正常进行反序列化,而test2执行将会报错java.lang.NumberFormatException。

fastjson版本:1.2.58
jdk版本:1.8.0_18

进行初步定位是com.alibaba.fastjson.parser.DefaultJSONParser第854行对于可变参数的特殊支持导致,可供参考。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants