Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO 4.2] ConcurrentModificationException in native with EAllContents() while not in legacy
[CDO 4.2] ConcurrentModificationException in native with EAllContents() while not in legacy [message #1051803] Mon, 29 April 2013 08:35 Go to next message
Eclipse UserFriend
Hi CDO Team,

We have and we use some code which iterates through a call to
eAllContents() and in this iteration we modify the model on which we do
iteration. I understand that it is a bad use of iterator because the
model must not be changed during iteration, but this works fine in
legacy while in native it throws a ConcurrentModificationException. And
like we have several snippets of code which do that we would like to
have this code works in native like in legacy. I have attached a junit
test based on CDO test framework to show the native/legacy difference.

Best Regards.

/*
* Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Esteban Dugueperoux - initial API and implementation
*/
package org.eclipse.emf.cdo.tests.bugzilla;

import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model3.Model3Factory;
import org.eclipse.emf.cdo.tests.model3.NodeA;

import org.eclipse.emf.ecore.EObject;

import java.util.Iterator;

/**
* @author Esteban Dugueperoux
*/
public class Bugzilla_440XXX_Test extends AbstractCDOTest
{
@CleanRepositoriesBefore
public void testEAllContents() throws Exception
{
NodeA nodeA1 = Model3Factory.eINSTANCE.createNodeA();
NodeA nodeA2 = Model3Factory.eINSTANCE.createNodeA();
nodeA2.setName("nodeA2");
NodeA nodeA3 = Model3Factory.eINSTANCE.createNodeA();
NodeA nodeA4 = Model3Factory.eINSTANCE.createNodeA();
nodeA1.getChildren().add(nodeA2);
nodeA2.getChildren().add(nodeA3);

Iterator<EObject> eAllContents = nodeA1.eAllContents();
while (eAllContents.hasNext())
{
EObject next = eAllContents.next();
if (next instanceof NodeA)
{
NodeA nodeA = (NodeA)next;
if ("nodeA2".equals(nodeA.getName()))
{
nodeA.getChildren().add(nodeA4);
}
}
}
}
}
Re: [CDO 4.2] ConcurrentModificationException in native with EAllContents() while not in legacy [message #1059540 is a reply to message #1051803] Mon, 20 May 2013 11:34 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 29.04.2013 10:35, schrieb news.eclipse.org:
> Hi CDO Team,
>
> We have and we use some code which iterates through a call to eAllContents() and in this iteration we modify the
> model on which we do iteration. I understand that it is a bad use of iterator because the model must not be changed
> during iteration,
Yeah, bad. Don't do it. Maybe Ed knows why that's possible...

> but this works fine in legacy while in native it throws a ConcurrentModificationException.
CDOObjectImpl used to extend EObjectImpl, while legacy (normal) objects usually extend MinimalEObject. I can only guess
that this makes a difference but we've recently changed CDOObjectImpl to extend MinimalEObject, too:

400388: Integrate the new MinimalEStoreEObjectImpl
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400388

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


> And like we have several snippets of code which do that we would like to have this code works in native like in
> legacy. I have attached a junit test based on CDO test framework to show the native/legacy difference.
>
> Best Regards.


Previous Topic:[CDO] We are trying to get CDO running on Oracle 11g
Next Topic:order of entries in EMap when load from xml
Goto Forum:
  


Current Time: Sat Apr 20 03:00:58 GMT 2024

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

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

Back to the top