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] 序列化"00000000" Date 空指针 #1711

Closed
zoze0 opened this issue Aug 3, 2023 · 2 comments
Closed

[BUG] 序列化"00000000" Date 空指针 #1711

zoze0 opened this issue Aug 3, 2023 · 2 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@zoze0
Copy link
Contributor

zoze0 commented Aug 3, 2023

问题描述

环境信息

  • JDK信息:JDK1.8
  • 版本信息:Fastjson2 2.0.38

重现步骤

// Bean
public class MyBean {
    private Date now;

    public Date getNow() {
        return now;
    }

    public void setNow(Date now) {
        this.now = now;
    }

    @Override
    public String toString() {
        return "MyBean{" +
                "now=" + now +
                '}';
    }
}
// main
public static void main(String[] args) {
        Map map = new HashMap();
        map.put("now", "00000000");
       // Hutool BeanUtil
        final MyBean bean = BeanUtil.mapToBean(map, MyBean.class, false, null);
        SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(fmt.format(bean.getNow()));
        System.out.println(JSON.toJSONString(bean));
    }

相关日志输出

Caused by: java.lang.NullPointerException
	at com.alibaba.fastjson2.writer.FieldWriterDate.writeDate(FieldWriterDate.java:298)
	at com.alibaba.fastjson2.writer.OWG_1_1_MyBean.write(Unknown Source)
	at com.alibaba.fastjson2.JSON.toJSONString(JSON.java:2756)
	... 1 more
@zoze0 zoze0 added the bug Something isn't working label Aug 3, 2023
@wenshao
Copy link
Member

wenshao commented Aug 13, 2023

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.39-SNAPSHOT/
问题已修复,请帮忙用2.0.39-SNAPSHOT版本验证,2.0.39版本预计在8月27日前发布

@wenshao wenshao added this to the 2.0.39 milestone Aug 13, 2023
@wenshao wenshao added the fixed label Aug 13, 2023
@wenshao
Copy link
Member

wenshao commented Aug 15, 2023

@wenshao wenshao closed this as completed Aug 15, 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

2 participants