Caused by: java.util.ConcurrentModificationException: null fastjson

  • 错误信息:

Caused by: java.util.ConcurrentModificationException: null
at java.util.HashMapHashIterator.nextNode(HashMap.java:1442) [na:1.8.0171]atjava.util.HashMapHashIterator.nextNode(HashMap.java:1442) ~[na:1.8.0_171] at java.util.HashMapHashIterator.nextNode(HashMap.java:1442) [na:1.8.01​71]atjava.util.HashMapEntryIterator.next(HashMap.java:1476) ~[na:1.8.0_171]
at java.util.HashMap$EntryIterator.next(HashMap.java:1474) ~[na:1.8.0_171]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:103) ~[fastjson-1.2.38.jar:na]
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:43) ~[fastjson-1.2.38.jar:na]
at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:278) ~[fastjson-1.2.38.jar:na]
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:652) ~[fastjson-1.2.38.jar:na]
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:594) ~[fastjson-1.2.38.jar:na]
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:559) ~[fastjson-1.2.38.jar:na]

  • 错误原因分析:

    由于转换json的时候,有其他线程修改了转换的对象,为多线程并发问题。

  • 解决方案:
    转换json的时候复制需要转换的对象为新对象。

上一篇:【异常】Caused by: java.lang.IllegalStateException: Zip64 archives are not supported


下一篇:hadoop Caused by: java.lang.ClassCastException