[EMF Compare] merge problem [message #134579] |
Tue, 31 March 2009 11:42  |
Eclipse User |
|
|
|
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 #620773 is a reply to message #134579] |
Wed, 01 April 2009 03:59  |
Eclipse User |
|
|
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03692 seconds