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] because "this.defaultCreator" is null -- JSON.parseObject() #362

Closed
countree opened this issue May 27, 2022 · 3 comments
Closed
Labels
bug Something isn't working
Milestone

Comments

@countree
Copy link

问题描述

简要描述您碰到的问题。
Cannot invoke "java.util.function.Supplier.get()" because "this.defaultCreator" is null
java.lang.NullPointerException: Cannot invoke "java.util.function.Supplier.get()" because "this.defaultCreator" is null
at com.alibaba.fastjson2.reader.ObjectReader3.readObject(ObjectReader3.java:233)
at com.alibaba.fastjson2.reader.FieldReaderObjectMethod.readFieldValue(FieldReaderObjectMethod.java:90)
at com.alibaba.fastjson2.reader.ObjectReaderBean.readObject(ObjectReaderBean.java:174)
at com.alibaba.fastjson2.JSON.parseObject(JSON.java:258)

环境信息

请填写以下信息:

  • OS信息: win10
  • JDK信息:jdk17
  • 版本信息:fastjson2 2.0.4

重现步骤

如何操作可以重现该问题:

String text = "{\"username\":\"dfs\",\"name\":\"电风扇\",\"exception\":\"\"}";
JSON.parseObject(text, User.class);

//执行就报异常
java.lang.NullPointerException: Cannot invoke "java.util.function.Supplier.get()" because "this.defaultCreator" is null

期待的正确结果

对您期望发生的结果进行清晰简洁的描述。

相关日志输出

请复制并粘贴任何相关的日志输出。

附加信息

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

@countree countree added the bug Something isn't working label May 27, 2022
@countree countree changed the title [BUG] because "this.defaultCreator" is null [BUG] because "this.defaultCreator" is null -- JSON.parseObject() May 27, 2022
@wenshao
Copy link
Member

wenshao commented May 27, 2022

User类的代码能提供下么?

@countree
Copy link
Author

countree commented May 30, 2022

我知道了,应该是有个Exception的字段,删掉后就正常了。

@Data
public class User{
 private BusinessException exception;
}

public class BusinessException extends RuntimeException{
}

@wenshao wenshao added this to the 2.0.7 milestone Jun 5, 2022
@wenshao wenshao closed this as completed Jun 11, 2022
@wenshao wenshao reopened this Jun 11, 2022
@wenshao
Copy link
Member

wenshao commented Jun 11, 2022

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

@wenshao wenshao closed this as completed Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants