Skip to content
New issue

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

[BUG]当javaBean当中包括非属性的get方法且返回类型与属性一致时,使用fastjson2反序列化失败,fastjson1没问题 #732

Closed
tangjwtj opened this issue Sep 5, 2022 · 3 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@tangjwtj
Copy link

tangjwtj commented Sep 5, 2022

问题描述

[BUG]当javaBean当中包括非属性的get方法且返回类型与属性一致时,使用fastjson2反序列化失败,fastjson1没问题

环境信息

  • OS信息: [Win 10]
  • JDK信息: [jdk1.8.0_291]
  • 版本信息:[Fastjson2 2.0.12]

重现步骤

public class SimpleDto{
    private List<String> testProperty;

    public List<String> getTestProperty() {
        return testProperty;
    }

    public void setTestProperty(List<String> testProperty) {
        this.testProperty = testProperty;
    }

    public List<String> getTestMethod(){
        return null;
    }
    public static void main(String[] args) {
        com.alibaba.fastjson.JSON.parseObject("{\"testProperty\":null}",SimpleDto.class);
        JSON.parseObject("{\"testProperty\":null}",SimpleDto.class);
    }
}

期待的正确结果

可以反序列化成功

相关日志输出

Exception in thread "main" com.alibaba.fastjson2.JSONException: json format error, offset 17, character n, line 1, column 18, fastjson-version 2.0.12 {"testProperty":null}
	at com.alibaba.fastjson2.reader.FieldReaderListStrMethod.readFieldValue(FieldReaderListStrMethod.java:100)
	at com.alibaba.fastjson2.reader.ObjectReader2.readObject(ObjectReader2.java:264)
	at com.alibaba.fastjson2.JSON.parseObject(JSON.java:459)

附加信息

如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。

@tangjwtj tangjwtj added the bug Something isn't working label Sep 5, 2022
@wenshao
Copy link
Member

wenshao commented Sep 5, 2022

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.13-SNAPSHOT/
问题已经修复,请用2.0.13-SNAPSHOT版本验证,2.0.13版本预计在9月12日前发布

@wenshao wenshao added this to the 2.0.13 milestone Sep 5, 2022
@wenshao wenshao added the fixed label Sep 5, 2022
@tangjwtj tangjwtj closed this as completed Sep 6, 2022
@tangjwtj
Copy link
Author

tangjwtj commented Sep 6, 2022

使用2.0.13-SNAPSHOT版本验证OK

@wenshao
Copy link
Member

wenshao commented Sep 10, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.13
2.0.13版本已经发布,请用帮忙用新版本验证

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants