Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 363802

Summary: [Texo] "clear list" feature causes ConcurrentModificationException
Product: [Modeling] EMFT Reporter: R. Oldenburg <roland.oldenburg>
Component: TexoAssignee: Martin Taal <mtaal>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.5   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

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