[ https://issues.apache.org/jira/browse/FELIX-4361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pierre De Rop updated FELIX-4361: --------------------------------- Fix Version/s: dependencymanager-3.2.0 > Possible ConcurrentModificationException in DependencyManager.getComponents() > ----------------------------------------------------------------------------- > > Key: FELIX-4361 > URL: https://issues.apache.org/jira/browse/FELIX-4361 > Project: Felix > Issue Type: Bug > Components: Dependency Manager > Affects Versions: dependencymanager-3.1.0 > Reporter: Paul Bakker > Assignee: Marcel Offermans > Fix For: dependencymanager-3.2.0 > > Attachments: FELIX-4361.patch > > > DependencyManager.getComponents() returns a unmodifiableList created as > follows: > {code} > Collections.unmodifiableList(m_components); > {code} > However, this does not provide safe iteration on the result of calling this > method. E.g. the following can fail with a ConcurrentModificationException: > {code} > List<ComponentDeclaration> components = dm.getComponents(); > for (ComponentDeclaration c : components) { > //do something > } > {code} > This is possible because the underlaying collection can be modified during > iteration. Wrapping it in an unmodifiable list doesn't prevent this, because > the modifications are done on the original list. > This can be fixed by copying the list to a new collection before returning. > This is more expensive, but the only way to be safe. > Patch and test provided. -- This message was sent by Atlassian JIRA (v6.2#6252)