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

hashMap key为null时序列化失败,报空指针[BUG] #697

Closed
dyj2012 opened this issue Aug 17, 2022 · 5 comments
Closed

hashMap key为null时序列化失败,报空指针[BUG] #697

dyj2012 opened this issue Aug 17, 2022 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@dyj2012
Copy link

dyj2012 commented Aug 17, 2022

问题描述

简要描述您碰到的问题。
hashMap key为null时序列化失败,报空指针

Caused by: java.lang.NullPointerException
	at com.alibaba.fastjson2.writer.ObjectWriterImplMap.writeJSONB(ObjectWriterImplMap.java:230) ~[fastjson2-2.0.6.jar!/:?]
	at com.alibaba.fastjson2.writer.ObjectWriterImplMap.writeJSONB(ObjectWriterImplMap.java:298) ~[fastjson2-2.0.6.jar!/:?]
	at com.alibaba.fastjson2.writer.ObjectWriterImplMap.writeJSONB(ObjectWriterImplMap.java:298) ~[fastjson2-2.0.6.jar!/:?]
	at com.alibaba.fastjson2.JSONB.toBytes(JSONB.java:873) ~[fastjson2-2.0.6.jar!/:?]
@dyj2012 dyj2012 added the bug Something isn't working label Aug 17, 2022
@wenshao
Copy link
Member

wenshao commented Aug 17, 2022

升级到2.0.11试下看问题是否还存在

@dyj2012
Copy link
Author

dyj2012 commented Aug 17, 2022

升级到2.0.11试下看问题是否还存在
存在
java.lang.NullPointerException
at com.alibaba.fastjson2.writer.ObjectWriterImplMap.writeJSONB(ObjectWriterImplMap.java:245)
at com.alibaba.fastjson2.JSONB.toBytes(JSONB.java:894)

    @Test
    public void toJSON() {
		HashMap<String, Object> map = new HashMap<>();
		map.put("1","1");
		map.put("2","2");
		map.put(null,"3");
		JSONB.toBytes(map, JSONWriter.Feature.WriteClassName);
    }

@dyj2012 dyj2012 changed the title [BUG] hashMap key为null时序列化失败,报空指针[BUG] Aug 17, 2022
@wenshao wenshao added this to the 2.0.12 milestone Aug 17, 2022
@wenshao
Copy link
Member

wenshao commented Aug 17, 2022

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

@dyj2012
Copy link
Author

dyj2012 commented Aug 18, 2022

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

验证通过

@wenshao
Copy link
Member

wenshao commented Aug 20, 2022

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

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