JD.CONCURJD.CONCUR is found when an iterator is created for collection A, then something is removed from the collection, but the loop is not stopped. For more information seeConcurrentModificationException Vulnerability and riskOn the following invocation of the "next" method, the code will throw a ConcurrentModificationException. Mitigation and preventionAn object under iteration cannot be modified. Elements for removal have to be stored in another collection and removed later, or the collection can be cloned and the iterator used on the cloned version. Example 112 void fixList(Collection col) { 13 for (Iterator iter = col.iterator(); iter.hasNext();) { 14 String el = (String) iter.next(); 15 if (el.startsWith("/")) { 16 col.remove(el); 17 } 18 } 19 } JD.CONCUR is reported for line 14: Possible 'ConcurrentModificationException' can be thrown by method 'iter.next()' while iterating over 'col'. You cannot remove a collection element while iterating over the same collection. |