Java concurrent modification exception

后端 未结 4 912
南笙
南笙 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:50

    Not sure you need to alter the keys of Map, it appears all you want to do is alter the values in the arrays.

    for(String[] values: dO.getParameterMap().values()) 
        for (int i = 0; i < values.length; i++) 
            values[i] = escapeHTML(values[i]);
    

    I would make sure the Map does have null values stored. But if you can't change this you will need to add if(values != null)

提交回复
热议问题