alibaba / fastjson

FASTJSON 2.0.x has been released, faster and more secure, recommend you upgrade.
https://github.com/alibaba/fastjson2/wiki/fastjson_1_upgrade_cn
Apache License 2.0
25.75k stars 6.5k forks source link

crash when Date filed included #4326

Closed Yan1025 closed 1 year ago

Yan1025 commented 1 year ago

when i deserialize a jsonstring that includes a java.util.Date filed like "Dec 7, 2022 10:55:19 AM"(that is produced by Gson serialize), there will be an error. logs bellow👇: java.lang.NumberFormatException: For input string: "Dec 7, 2022 2:36:01 PM" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_331] at java.lang.Long.parseLong(Long.java:589) ~[na:1.8.0_331] at java.lang.Long.parseLong(Long.java:631) ~[na:1.8.0_331] at com.alibaba.fastjson.serializer.DateCodec.cast(DateCodec.java:339) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.deserializer.AbstractDateDeserializer.deserialze(AbstractDateDeserializer.java:184) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.deserializer.AbstractDateDeserializer.deserialze(AbstractDateDeserializer.java:16) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.deserializer.DefaultFieldDeserializer.parseField(DefaultFieldDeserializer.java:88) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.parseField(JavaBeanDeserializer.java:1278) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:893) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.parseRest(JavaBeanDeserializer.java:1624) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.deserializer.FastjsonASMDeserializer_1_FlowRuleEntity.deserialze(Unknown Source) ~[na:na] at com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer.deserialze(JavaBeanDeserializer.java:287) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:792) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:726) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.parser.DefaultJSONParser.parseArray(DefaultJSONParser.java:721) ~[fastjson-1.2.83_noneautotype.jar:na] at com.alibaba.fastjson.JSON.parseArray(JSON.java:643) ~[fastjson-1.2

Yan1025 commented 1 year ago

This bug has been resolved in fastjson2 project👉 https://github.com/alibaba/fastjson2/issues/997