Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Compare] merge problem
[EMF Compare] merge problem [message #134579] Tue, 31 March 2009 11:42 Go to next message
Eclipse UserFriend
Hello,

I'd like to use the Merge service of the EMF compare project.
I can load ecore models from resources and I can create Match and
DiffModels ( using the Match and DiffService ), but when I get the
diffModel and I'd like to merge one of the parent model with the diff I
get the following exception:

java.util.ConcurrentModificationException
at
org.eclipse.emf.common.util.AbstractEList$EIterator.checkMod Count(AbstractEList.java:762)
at
org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(A bstractEList.java:716)
at
org.eclipse.emf.common.util.AbstractEList$EIterator.next(Abs tractEList.java:696)
at
org.eclipse.emf.compare.diff.merge.service.MergeService.merg e(MergeService.java:132)
at ...

Here is my code:

File file1 = getFileByFileName("v1.ecore");
File file2 = getFileByFileName("v2.ecore");
ResourceSet set = new ResourceSetImpl();
EObject root1 = ModelUtils.load(file1, set);
EObject root2 = ModelUtils.load(file2, set);
MatchModel matchModel = MatchService.doMatch(root1, root2, null);
DiffModel diffModel = DiffService.doDiff(matchModel);

MergeService.merge(diffModel.getOwnedElements(), true);


What should I have to do?

Regards,
Fermo
Re: [EMF Compare] merge problem [message #134597 is a reply to message #134579] Wed, 01 April 2009 03:59 Go to previous messageGo to next message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------090300080904050307050002
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi fermo,

There is a known possibility of ConcurrentModificationExceptions to be
thrown with the MergeService. To quote the Javadoc of
MergeService#merge(List<DiffElement>, boolean) :

@throws ConcurrentModificationException
Could be thrown if the list you give is directly a
reference from the meta model such as
{@link DiffModel#getOwnedElements()} or {@link
DiffElement#getSubDiffElements()}. Copy the
list before merging it.

and looking at your code, this is exactly what you're doing. You can
work around it by replacing
MergeService.merge(diffModel.getOwnedElements(), true);
for
MergeService.merge(new
ArrayList<DiffElement>(diffModel.getOwnedElements()), true);

I do not copy the list in the merge code because of history reasons ...
this might be changeable now.

Laurent Goubet
Obeo

fermo a
Re: [EMF Compare] merge problem [message #134612 is a reply to message #134597] Wed, 01 April 2009 05:43 Go to previous message
Eclipse UserFriend
Hi Laurent

Thank you very much for you help!

Regards,
Fermo
Re: [EMF Compare] merge problem [message #620773 is a reply to message #134579] Wed, 01 April 2009 03:59 Go to previous message
Eclipse UserFriend
This is a multi-part message in MIME format.
--------------090300080904050307050002
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi fermo,

There is a known possibility of ConcurrentModificationExceptions to be
thrown with the MergeService. To quote the Javadoc of
MergeService#merge(List<DiffElement>, boolean) :

@throws ConcurrentModificationException
Could be thrown if the list you give is directly a
reference from the meta model such as
{@link DiffModel#getOwnedElements()} or {@link
DiffElement#getSubDiffElements()}. Copy the
list before merging it.

and looking at your code, this is exactly what you're doing. You can
work around it by replacing
MergeService.merge(diffModel.getOwnedElements(), true);
for
MergeService.merge(new
ArrayList<DiffElement>(diffModel.getOwnedElements()), true);

I do not copy the list in the merge code because of history reasons ...
this might be changeable now.

Laurent Goubet
Obeo

fermo a
Re: [EMF Compare] merge problem [message #620774 is a reply to message #134597] Wed, 01 April 2009 05:43 Go to previous message
Eclipse UserFriend
Hi Laurent

Thank you very much for you help!

Regards,
Fermo
Previous Topic:[EMF Compare] merge problem
Next Topic:EEF Toolchain
Goto Forum:
  


Current Time: Tue Sep 16 19:13:14 EDT 2025

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

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

Back to the top