alibaba / fastjson2

🚄 FASTJSON2 is a Java JSON library with excellent performance.
Apache License 2.0
3.78k stars 495 forks source link

[BUG]国产鲲鹏服务器会出现com.alibaba.fastjson2.JSONException: syntax error : f(目前观察结果是不稳定,不能每次复现) #2210

Closed 1195952223 closed 6 months ago

1195952223 commented 9 months ago

问题描述

环境信息

请填写以下信息: image

重现步骤

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

JSONObject.from(map).toString() map数据如下 {"dataun":"0002020015001011","mlcd":"","uuid":null,"pdcd":"Y2023","bzcode":"DATJ","tt_id":"T2301","datas":[{"data":[{"pdcd":"Y2023","tb_un":"0002020015001011"},{"DA3_078":46,"DA3_028_01":37,"DA3_053":36,"DA3_054":637,"DA3_030_01":3.6,"DA3_029_01":962,"DA3_077":96,"DA3_076":1,"DA3_025_01":1,"DA3_027_01":1,"DA3_026_01":1,"DA3_041_01":4,"DA3_042_01":326,"DA3_053_01":33,"DA3_054_01":636,"PUB05":"xxxxx","PUB08":"xxx","PUB02":"xxx","PUB03":"075","PUB04":"422000","PUB01":"11430511MB10830639","PUB09":"XXX","DA3_076_01":1,"DA3_078_01":45,"DA3_091_01":"2","DA3_092_01":29,"DA3_093_01":35,"DA3_089_01":"2","DA3_025":1,"DA3_026":1,"DA3_090_01":"2","DA3_099_01":18,"DA3_098_01":18,"PUB10":"XX","DA3_098":18,"DA3_099":8,"DA3_041":6,"DA3_042":327,"DA3_093":5,"DA3_092":29,"DA3_027":1,"DA3_028":40,"DA3_029":963,"PUB07":"2023","DA3_030":3.8,"PUB06":"0739-5180709"}],"tt_ver_n":"01","ts_cd":"S03","hasml":false,"ts_un":"0","hasdata":false}],"noAftercal":true}

期待的正确结果

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

相关日志输出

请复制并粘贴任何相关的日志输出。 com.alibaba.fastjson2.JSONException: syntax error : f at com.alibaba.fastjson2.JSONReaderUTF16.readBoolValue(JSONReaderUTF16.java:6424) at com.alibaba.fastjson2.JSONReader.readObject(JSONReader.java:2347) at com.alibaba.fastjson2.JSONReader.readArray(JSONReader.java:2594) at com.alibaba.fastjson2.JSONReader.read(JSONReader.java:2142) at com.alibaba.fastjson2.JSON.parse(JSON.java:67) at com.alibaba.fastjson2.JSON.toJSON(JSON.java:3506) at com.alibaba.fastjson2.JSON.toJSON(JSON.java:3469) at com.alibaba.fastjson2.JSONObject.from(JSONObject.java:2028)

附加信息

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

rowstop commented 9 months ago

哪个版本?给个 testcase?

1195952223 commented 9 months ago

2.0.45 参数就是上的json
但是这个不是每次都能复现 我本地没有出现过 在国产环境有时间会出现 上面的json就是出现时的前台传的信息 @RequestMapping("/saveData") public void saveData(@RequestBody Map param) throws Exception { String s = JSONObject.from(param).toString(); System.out.println(s); }

wenshao commented 9 months ago

奇怪了,我是在阿里云的倚天710 ARM机器上测试过没问题的,鲲鹏不知道是什么架构,没有环境

1195952223 commented 9 months ago

使用JSON.toJSONString(param, JSONWriter.Feature.FieldBased, JSONWriter.Feature.WriteNullStringAsEmpty);代替了 目前没有在报错了 在观察观察

luckytao commented 6 months ago

2502 看下我提交的这个bug,我也是鲲鹏服务器上,不是每次必现

wenshao commented 6 months ago

@luckytao 这个问题在linux aarch64 jdk8下会偶发,我也没找到原因,现在的做法是JDK8就换一种实现。

wenshao commented 6 months ago

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

最新版本的快照版本已经在多种aarch64架构的服务器上通过JDK8/11/17测试,包括:

阿里云倚天710 华为云鲲鹏服务 Amazon EC2 C7g (Arm-based AWS Graviton3) Orange Pi5 Plus RK3588 Orange Pi Aipro (昇腾)

wenshao commented 6 months ago

https://github.com/alibaba/fastjson2/releases/tag/2.0.50 2.0.50已发布,请用新版本