Caused by: java.util.ConcurrentModificationException: null fastjson

  • 错误信息:

Caused by: java.util.ConcurrentModificationException: null
at java.util.HashMap H a s h I t e r a t o r . n e x t N o d e ( H a s h M a p . j a v a : 1442 )   [ n a : 1.8. 0 1 71 ] a t j a v a . u t i l . H a s h M a p HashIterator.nextNode(HashMap.java:1442) ~[na:1.8.0_171] at java.util.HashMap HashIterator.nextNode(HashMap.java:1442) [na:1.8.0171]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的时候复制需要转换的对象为新对象。

你可能感兴趣的:(并发编程)