Menu

#556 Validate within for each style loop no remove on collection

open
nobody
rules (229)
5
2014-08-21
2010-12-03
No

This is unsafe behavior as the iterator that is created by the syntax in not aware of the collection being mutated. See discussion here http://stackoverflow.com/questions/1196586/calling-remove-in-foreach-loop-in-java. I think this would need to be a java code rule to validate that remove is actually being called on the collection being iterated. I tried with just XPath, but you get false positives because you can't correlate the 2 variable names (the one remove is called on and the one in the for loop statement.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.