...
Code Block | ||
---|---|---|
| ||
class BadIterate { public static void main(String[] args) { List<String>List<String> list = new ArrayList<String>ArrayList<String>(); list.add("one""one"); list.add("two""two"); Iterator iter = list.iterator(); while(iter.hasNext()) { String s = (String)iter.next(); if(s.equals("one""one")) list.remove(s); } } } |
Compliant Solution
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
References
Wiki Markup |
---|
\[[API 06|AA. Java References#API 06]\] Class [ConcurrentModificationException|http://java.sun.com/j2se/1.5.0/docs/api/java/util/ConcurrentModificationException.html] \[[SDN 08|AA. Java References#SDN 08]\] [Sun Bug database, Bug ID:6687277|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6687277] \[[Goetz 06|AA. Java References#Goetz 06]\] 5.1.2. Iterators and Concurrentmodificationexception |
...
MSC32-J. Make sensitive classes noncloneable 49. Miscellaneous (MSC) 99. The Void (VOID)