[ https://issues.apache.org/jira/browse/ARTEMIS-1411?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16163645#comment-16163645 ]
Timothy Bish commented on ARTEMIS-1411: --------------------------------------- I don't think this is actually an issue based on the code backing the processes collection which is a ConcurrentHashMap which should be fine with concurrent modification of the collection. It's not the most intuitive code but I don't think there is a problem. The code essentially boils down to something like this which would work: {code} ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>(); map.put("A", "1"); map.put("B", "2"); map.put("C", "3"); assertFalse(map.isEmpty()); for (String key : map.keySet()) { map.remove(key); } assertTrue(map.isEmpty()); {code} > Coverity: Using invalid iterator in ProcessBuilder.java > ------------------------------------------------------- > > Key: ARTEMIS-1411 > URL: https://issues.apache.org/jira/browse/ARTEMIS-1411 > Project: ActiveMQ Artemis > Issue Type: Bug > Components: Broker > Affects Versions: 2.4.0 > Reporter: Jiri Danek > Priority: Minor > > {noformat} > 48 public static void cleanupProcess() { > 1. enhanced_for: Starting an iteration on > org.apache.activemq.artemis.cli.process.ProcessBuilder.processes. > 2. Iterating over another element of > org.apache.activemq.artemis.cli.process.ProcessBuilder.processes. > > CID 1409570 (#1 of 1): Using invalid iterator (INVALIDATE_ITERATOR) > 5. invalid_loop: Attempting to obtain another element from > org.apache.activemq.artemis.cli.process.ProcessBuilder.processes after it's > been modified. > 49 for (Process p : processes) { > 50 // if (!p.isAlive()) > 51 { > 3. modify_iterable: Call to remove modifies Iterable > org.apache.activemq.artemis.cli.process.ProcessBuilder.processes which > invalidates the iterator for the loop on that Iterable. [Note: The source > code implementation of the function has been overridden by a builtin model.] > 52 processes.remove(p); > 53 } > 4. Jumping back to the beginning of the loop. > 54 } > 55 } > {noformat} -- This message was sent by Atlassian JIRA (v6.4.14#64029)