Java concurrent modification exception

后端 未结 4 913
南笙
南笙 2021-01-21 08:24

I have written following code which is resulting in concurrent modification exception. How can I prevent it ? The idea is to escape all values of the Map and reconstruct the obj

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-21 08:48

    the exception is thrown because you are adding/removing things from the map while you are iterating it:

    dO.removeParameter(entry.getKey());
    dO.addParameter(entry.getKey(),valList.toArray(new String[valList.size()]
    

    you should use iterator.remove() instead.

提交回复
热议问题