Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 363802 - [Texo] "clear list" feature causes ConcurrentModificationException
Summary: [Texo] "clear list" feature causes ConcurrentModificationException
Status: RESOLVED FIXED
Alias: None
Product: EMFT
Classification: Modeling
Component: Texo (show other bugs)
Version: 0.5   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Martin Taal CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-15 06:40 EST by R. Oldenburg CLA
Modified: 2011-11-15 22:51 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description R. Oldenburg CLA 2011-11-15 06:40:37 EST
When generating bi-directional support for a ordered 1:n-relation then there are some generated features handling the changes that need to be applied to the "n"-list.

The method "clearXYZ" seems to be generated incorrectly as it:
- iterates over the list with an foreach (for XYZ xyz : XYZs)
- and calls "removeXYZ" for every entry (which handles the bi-directional remove)

This consequently leads to an ConcurrentModificationException because the list ( which it currently iterates on) is being modified (entries are removed).

Imo there are two possible solutions:
- Iterate over a copy of the org. list (i.e. for (XYZ xyz : new ArrayList<XYZ>(XYZs))
or
- simply remove the first entry from the list until it is empty
Code: [Select all] [Show/ hide]

while (!XYZs.isEmpty()) {
 removeXYZ(XYZs.get(0));
}
Comment 1 Martin Taal CLA 2011-11-15 22:51:44 EST
I have changed the code generation and added a testcase. So this should now be solved. I published a new build containing these issues.

Please re-open this issue if it is still encountered.

gr. Martin