Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] "clear list" feature causes ConcurrentModificationException(Generated code seems invalid)
icon5.gif  [Texo] "clear list" feature causes ConcurrentModificationException [message #756811] Tue, 15 November 2011 08:56 Go to next message
R. Oldenburg is currently offline R. OldenburgFriend
Messages: 24
Registered: September 2011
Junior Member
Hi,

don't know if I am using the latest Texo version (downloaded it approx. 1 month ago).
Will have a look at it.

So maybe this is already fixed.

The issue:
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
while (!XYZs.isEmpty()) {
 removeXYZ(XYZs.get(0));
}


Keep on the good work.
Thanks a lot for this tool and regards,
Roland
Re: [Texo] &quot;clear list&quot; feature causes ConcurrentModificationException [message #756863 is a reply to message #756811] Tue, 15 November 2011 11:35 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Roland,
Seems indeed like a bug, can you enter a bugzilla on Texo?
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EMFT&component=Texo&version=0.5

with the same description/text then I will pick it up.

gr. Martin

On 11/15/2011 09:56 AM, R. Oldenburg wrote:
> Hi,
>
> don't know if I am using the latest Texo version (downloaded it approx. 1 month ago).
> Will have a look at it.
>
> So maybe this is already fixed.
>
> The issue:
> 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
> while (!XYZs.isEmpty()) {
> removeXYZ(XYZs.get(0));
> }
>
> Keep on the good work.
> Thanks a lot for this tool and regards,
> Roland


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:Using EMF generated codes in external java codes
Next Topic:Duplicated ecore models !!
Goto Forum:
  


Current Time: Sat Dec 05 00:55:28 GMT 2020

Powered by FUDForum. Page generated in 0.02757 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top