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

Bug 345858

Summary: CrossReferenceAdapter can cause problems when attached to the RootResource
Product: [Modeling] EMF Reporter: Martin Fluegge <martin.fluegge>
Component: cdo.coreAssignee: Martin Fluegge <martin.fluegge>
Status: CLOSED DUPLICATE QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 CC: martin.fluegge, stepper
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Test v1
none
Patch v1
none
Patch v2
none
UI Test v1
none
Patch for Bugzilla_337523_Test none

Description Martin Fluegge CLA 2011-05-15 16:59:43 EDT
While opening a Dawn diagram resource the attached exception occurs. This only happens if the repository already contains two sets of resources (*.acore + *.acorediagram). It seems that the problem is somehow related to Bug 337523, because the problem appears since this bug was fixed. 
Following the stack trace this does not seem to be a Dawn problem, but a CDO/CrossreferenceAdapter problem.

[ERROR] Different object was registered for OID14
java.lang.IllegalStateException: Different object was registered for OID14
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.registerObject(AbstractCDOView.java:1076)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:704)
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.getObject(CDOTransactionImpl.java:1018)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1011)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:660)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToEMF(CDOStoreImpl.java:628)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.get(CDOStoreImpl.java:187)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.isSet(CDOStoreImpl.java:219)
	at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.revisionToInstanceFeature(CDOLegacyWrapper.java:463)
	at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.revisionToInstance(CDOLegacyWrapper.java:403)
	at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.cdoInternalPostLoad(CDOLegacyWrapper.java:282)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.cleanObject(AbstractCDOView.java:865)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.createObject(AbstractCDOView.java:803)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:699)
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.getObject(CDOTransactionImpl.java:1018)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1011)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:660)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToEMF(CDOStoreImpl.java:628)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.get(CDOStoreImpl.java:187)
	at org.eclipse.emf.ecore.impl.EStoreEObjectImpl$BasicEStoreEList.delegateGet(EStoreEObjectImpl.java:247)
	at org.eclipse.emf.common.util.DelegatingEList.primitiveGet(DelegatingEList.java:267)
	at org.eclipse.emf.common.util.AbstractEList$NonResolvingEListIterator.doNext(AbstractEList.java:1063)
	at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:696)
	at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:443)
	at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.setTarget(TransactionChangeRecorder.java:155)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:127)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didAdd(CDOObjectImpl.java:419)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didAdd(CDOObjectImpl.java:1)
	at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:425)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:199)
	at org.eclipse.emf.ecore.change.util.ChangeRecorder.addAdapter(ChangeRecorder.java:700)
	at org.eclipse.emf.ecore.change.util.ChangeRecorder.notifyChanged(ChangeRecorder.java:319)
	at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:218)
	at org.eclipse.emf.cdo.dawn.transaction.DawnTransactionChangeRecorder.notifyChanged(DawnTransactionChangeRecorder.java:45)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatchNotification(NotifyingListImpl.java:267)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:300)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:426)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:239)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:391)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getResource(AbstractCDOView.java:493)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.newResourceInstance(AbstractCDOView.java:824)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.createObject(AbstractCDOView.java:794)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:699)
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.getObject(CDOTransactionImpl.java:1018)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1011)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:660)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToEMF(CDOStoreImpl.java:628)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.get(CDOStoreImpl.java:187)
	at org.eclipse.emf.ecore.impl.EStoreEObjectImpl$BasicEStoreEList.delegateGet(EStoreEObjectImpl.java:247)
	at org.eclipse.emf.common.util.DelegatingEList.primitiveGet(DelegatingEList.java:267)
	at org.eclipse.emf.common.util.AbstractEList$NonResolvingEListIterator.doNext(AbstractEList.java:1063)
	at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:696)
	at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.hasNext(EContentsEList.java:486)
	at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImpl.next(EContentsEList.java:565)
	at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.setTarget(TransactionChangeRecorder.java:156)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:127)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didAdd(CDOObjectImpl.java:419)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didAdd(CDOObjectImpl.java:1)
	at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:425)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:199)
	at org.eclipse.emf.ecore.change.util.ChangeRecorder.addAdapter(ChangeRecorder.java:700)
	at org.eclipse.emf.ecore.change.util.ChangeRecorder.notifyChanged(ChangeRecorder.java:319)
	at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:218)
	at org.eclipse.emf.cdo.dawn.transaction.DawnTransactionChangeRecorder.notifyChanged(DawnTransactionChangeRecorder.java:45)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatchNotification(NotifyingListImpl.java:267)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:300)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.setRootResource(AbstractCDOView.java:218)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:708)
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.getObject(CDOTransactionImpl.java:1018)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1011)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:660)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.getResource(CDOStoreImpl.java:163)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl.eDirectResource(CDOObjectImpl.java:456)
	at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.eDirectResource(CDOResourceImpl.java:199)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInternalResource(BasicEObjectImpl.java:931)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl.eInternalResource(CDOObjectImpl.java:467)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResource(BasicEObjectImpl.java:926)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.setTarget(CrossReferenceAdapter.java:384)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:127)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didAdd(CDOObjectImpl.java:419)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didAdd(CDOObjectImpl.java:1)
	at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:425)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:199)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.addAdapter(ECrossReferenceAdapter.java:822)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.handleContainment(ECrossReferenceAdapter.java:585)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.handleContainment(CrossReferenceAdapter.java:189)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.selfAdapt(ECrossReferenceAdapter.java:542)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.selfAdapt(CrossReferenceAdapter.java:92)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.notifyChanged(ECrossReferenceAdapter.java:430)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatchNotification(NotifyingListImpl.java:267)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:300)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:426)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:239)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:391)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getResource(AbstractCDOView.java:493)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.newResourceInstance(AbstractCDOView.java:824)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.createObject(AbstractCDOView.java:794)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:699)
	at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.getObject(CDOTransactionImpl.java:1018)
	at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1011)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:660)
	at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.getResource(CDOStoreImpl.java:163)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl.eDirectResource(CDOObjectImpl.java:456)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInternalResource(BasicEObjectImpl.java:931)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl.eInternalResource(CDOObjectImpl.java:467)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eResource(BasicEObjectImpl.java:926)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.setTarget(CrossReferenceAdapter.java:398)
	at org.eclipse.emf.ecore.impl.MinimalEObjectImpl$1ArrayDelegatingAdapterList.didAdd(MinimalEObjectImpl.java:503)
	at org.eclipse.emf.ecore.impl.MinimalEObjectImpl$1ArrayDelegatingAdapterList.didAdd(MinimalEObjectImpl.java:1)
	at org.eclipse.emf.common.util.ArrayDelegatingEList.addUnique(ArrayDelegatingEList.java:395)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.addAdapter(ECrossReferenceAdapter.java:822)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.setTarget(ECrossReferenceAdapter.java:703)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.setTarget(ECrossReferenceAdapter.java:677)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.setTarget(CrossReferenceAdapter.java:380)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:127)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didAdd(CDOObjectImpl.java:419)
	at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didAdd(CDOObjectImpl.java:1)
	at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:425)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:199)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.addAdapter(ECrossReferenceAdapter.java:822)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.handleContainment(ECrossReferenceAdapter.java:585)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.handleContainment(CrossReferenceAdapter.java:189)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.selfAdapt(ECrossReferenceAdapter.java:542)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.selfAdapt(CrossReferenceAdapter.java:92)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.notifyChanged(ECrossReferenceAdapter.java:430)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatchNotification(NotifyingListImpl.java:267)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:300)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:426)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:239)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:391)
	at org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreDocumentProvider.setDocumentContent(DawnAcoreDocumentProvider.java:146)
	at org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreDocumentProvider.createDocument(AcoreDocumentProvider.java:109)
	at org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreDocumentProvider.createElementInfo(AcoreDocumentProvider.java:88)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider.connect(AbstractDocumentProvider.java:387)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.doSetInput(DiagramDocumentEditor.java:460)
	at org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.DawnAcoreDiagramEditor.setInput(DawnAcoreDiagramEditor.java:59)
	at org.eclipse.gef.ui.parts.GraphicalEditor.init(GraphicalEditor.java:346)
	at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor.init(DiagramEditor.java:653)
	at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.init(DiagramDocumentEditor.java:126)
	at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:801)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:647)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
	at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
	at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
	at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
	at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
	at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198)
	at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:493)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
	at org.eclipse.ui.internal.PartStack.add(PartStack.java:479)
	at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
	at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
	at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
	at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
	at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:781)
	at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:680)
	at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:641)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
	at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2756)
	at org.eclipse.emf.cdo.dawn.ui.views.DawnExplorer$2.doubleClick(DawnExplorer.java:111)
	at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:845)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:843)
	at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1462)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1246)
	at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:249)
	at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:246)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:307)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4163)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3752)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 1 Martin Fluegge CLA 2011-05-15 17:03:09 EDT
Created attachment 195680 [details]
Test v1

Eike and I were trying to reproduce this problem in a test case but did not succeed yet. But I attach our work so we could continue...
Comment 2 Martin Fluegge CLA 2011-05-15 17:08:24 EDT
Created attachment 195683 [details]
Patch v1

Our assumption is that the cross reference adapter leads to some sort of recursion when the root resource is attached to the resource set. There are two different approaches to follow:

1.) make sure that adding the root resource to a resource set does not lead to a notification and prevent attaching the CR Adapter to the root resource and its children when the root resource is already attach to the resource set when the CR adapter is added.

2.) do not keep the root resource in the resource set.

This patch tries to implement 1.), but is not yet finished.
Comment 3 Martin Fluegge CLA 2011-05-16 03:44:06 EDT
O.k. rough idea, which follows the assumtion that new call of setRootResource in getObject might be related to the problem. 

This is just conceptual since I am at work an to not even have an eclispe in front of me.

If the created object is a root resource this leads to the call of setRootResource(), which in turn adds the resource to the resource set.

I am not sure about the detailed implementation of the list that holds the resources in the resourceSet, because running through the code is hard while just browsing the svn with a browser. ;)

But, if I have seen correctly the list is not unique, so calling setRootResource()  more than once would lead to adding the root resource multiple times, right?

If so (not sure about) shoudn't we take care of this fact in setRootResource() like this? 

  private synchronized void setRootResource(CDOResourceImpl resource)
  {
if(rootResource!=resource)
{
    rootResource = resource;
    rootResource.setRoot(true);
    registerObject(rootResource);
    getResourceSet().getResources().add(rootResource);
}
  }



I'll check this when I am at home (if I do not find out that my assumtion about the list implementation is incorrect ;) ).
Comment 4 Eike Stepper CLA 2011-05-16 03:52:33 EDT
(In reply to comment #3)
> But, if I have seen correctly the list is not unique, so calling
> setRootResource()  more than once would lead to adding the root resource
> multiple times, right?

Very unlikely. ResourceSet.resources is a bidirectional *containment* list. As such it's implicitely unique.

And we seem to have tests that check for the proper size of the resources list.
Comment 5 Martin Fluegge CLA 2011-05-16 04:22:59 EDT
Darn, then let's skip this idea :(
Comment 6 Martin Fluegge CLA 2011-05-17 17:04:08 EDT
Created attachment 195911 [details]
Patch v2

Think I fixed it. Registering and putting the root resource into the object map in getObject seems to lead to the nasty recursion. I excluded it and postponed the addition to the resource set. All test are passing and so are the manual Dawn tests. 

Capsar, could you have a look at the tell and say what you think about it?
Comment 7 Martin Fluegge CLA 2011-05-18 12:28:01 EDT
Created attachment 196002 [details]
UI Test v1

This test makes the problem reproducible. Please run it as SWTBot Test.
Comment 8 Martin Fluegge CLA 2011-05-19 02:01:43 EDT
I would like to increase the priority of this one from 3 to 2, because if this one is not solved in time it does not make sense to deliver Dawn for Indigo, since it is not useable.  

Eike, do you agree?
Comment 9 Caspar D. CLA 2011-05-19 03:33:35 EDT
(In reply to comment #6)
> Created attachment 195911 [details]
> Patch v2
> 
> Think I fixed it. Registering and putting the root resource into the object map
> in getObject seems to lead to the nasty recursion. I excluded it and postponed
> the addition to the resource set. All test are passing and so are the manual
> Dawn tests. 
> 
> Capsar, could you have a look at the tell and say what you think about it?

I'm not happy with this fix, because it doesn't prevent the bad state (i.e.
the rootResource being missing from the view's 'objects' map). Rather,
it fixes the state when a caller attempts to retrieve it, and thus pretends
that the bad state "never happened" -- but it did.

If I changed Bugzilla_337523_Test to retrieve the map with reflection
instead of going through the InternalCDOTransaction interface, the assertion
in the test would still fail, because the fix logic wouldn't get invoked.
Comment 10 Martin Fluegge CLA 2011-05-19 04:16:34 EDT
> I'm not happy with this fix, because it doesn't prevent the bad state (i.e.
> the rootResource being missing from the view's 'objects' map).

I am confused. My starting point was your test. It passes with the fix and does exactly what the test checks - that the root resource can be retrieved from the objects map. Did you apply patch2. Does your test case really fail?
Comment 11 Caspar D. CLA 2011-05-19 04:37:01 EDT
Btw, why is the test in the attachment annotated to be authored by
"Egidijus Vaisnora, Caspar De Groot"? A copy-and-paste mishap?
Comment 12 Caspar D. CLA 2011-05-19 04:40:14 EDT
(In reply to comment #10)
> > I'm not happy with this fix, because it doesn't prevent the bad state (i.e.
> > the rootResource being missing from the view's 'objects' map).
> 
> I am confused. My starting point was your test. It passes with the fix and does
> exactly what the test checks - that the root resource can be retrieved from the
> objects map. Did you apply patch2. Does your test case really fail?

No it does not, because your patch2 effectively corrects the bad state when
#getObjects is called.

But my point is that this isn't the right approach. You are fixing the bad
state when it is about to be detected, instead of preventing the bad state
from arising in the first place.

I'll update Bugzilla_337523_Test to probe the map using reflection, so 
as to make my point clear.
Comment 13 Caspar D. CLA 2011-05-19 05:06:38 EDT
Created attachment 196088 [details]
Patch for Bugzilla_337523_Test

Bugzilla_337523_Test updated to use reflection. This demonstrates
that "Patch v2" only hides/corrects the problem.. it doesn't prevent
the incorrect state from arising.
Comment 14 Martin Fluegge CLA 2011-05-19 06:30:47 EDT
Hi Caspar,

I do understand that you believe that having the rootResource not in the objects map directly after is creation should be treated as bad state. What I do not understand is why? The only one who is directly aware of the root resource and it storage is AbstractCDOView, so it can handle this fact itself. So I think this is rather an implementation detail. Noone else but the AbstractCDOView access the objects map directly. 

Accessing the objects field via reflection demonstrates that the root resource is not in, but I guess the no CDO committer will ever retrieve this information by reflection. And I cannot imagine why any CDO user should ever use reflection to get the data. Beside that this would actually be some sort of a hack.

The actual problem, and I agree that it is one, only arises from the usage of internal API (calling getObjects()). Any implemented method provided by public API will not run into this problem (e.g. getObject(..)) (as far as I can see).
Eike and I worked for several hours on this, but were unfortunately not able to reproduce this in a core test nor to understand every detail of the problem. But we strongly believe that this is not only related to legacy or Dawn, but a core problem. 

If there is a *must* for putting the root resource into the objects map as soon as possible after its creation, I think it would be better to find another way. Maybe it helps to put the changes from my patch directly to the place where your changes were active. So, simple do not call setResource(), but only register the object and skip the addition to the resource set. Can’t try this from here, but will check this as soon as I am home.

If you have any other idea how to solve this I would be thankful for your help :)
Comment 15 Eike Stepper CLA 2011-05-19 06:40:02 EDT
(In reply to comment #14)
> I do understand that you believe that having the rootResource not in the
> objects map directly after is creation should be treated as bad state. What I
> do not understand is why? The only one who is directly aware of the root
> resource and it storage is AbstractCDOView, so it can handle this fact itself.
> So I think this is rather an implementation detail. Noone else but the
> AbstractCDOView access the objects map directly. 

I agree.

> The actual problem, and I agree that it is one, only arises from the usage of
> internal API (calling getObjects()). Any implemented method provided by public
> API will not run into this problem (e.g. getObject(..)) (as far as I can see).
> Eike and I worked for several hours on this, but were unfortunately not able to
> reproduce this in a core test nor to understand every detail of the problem.

Both is needed, nonetheless!

> But we strongly believe that this is not only related to legacy or Dawn, but a
> core problem. 

Believing is not enough. We need a core test to proof that we've understood.

> If you have any other idea how to solve this I would be thankful for your help

I'm thinking about removing the laziness from the root resource initialization...
Comment 16 Caspar D. CLA 2011-05-19 07:00:28 EDT
(In reply to comment #14)

> I do understand that you believe that having the rootResource not in the
> objects map directly after is creation should be treated as bad state. 

No, you misunderstand right there. In general, the rootResource doesn't have
to be in the map. Lazy loading is a fine principle.

> What I do not understand is why? 

If you and Eike (just had a long discussion with him about this as well) looked
carefully at what Bugzilla_337523_Test tests, then you would see that right
before the map is tested for the presence of the root resource, the root
resource is

  * explicitly retrieved by its CDOID *

The bug that was reported in zilla 337523, is that the rootResource is still
not in the map even after being explicitly loaded!

Your fix *undoes* the patch for that, and my *enhanced* (i.e. uploaded today)
version of Bugzilla_337523_Test shows that your patch2 for *this* Zilla does
not address it.

Sorry if I sound repetitive.. but I do get the impression that you and Eike
are not carefully looking at what Bugzilla_337523_Test does. Please look again
at the code *before* the map is tested.
Comment 17 Eike Stepper CLA 2011-05-19 07:05:22 EDT
I think I did get that. My only objection relates to your argument that reflective access to implementation details is a (stronger) argument than the use of public API (like, technically, InternalCDOView).
Comment 18 Caspar D. CLA 2011-05-19 22:46:55 EDT
(In reply to comment #17)
> I think I did get that. My only objection relates to your argument that
> reflective access to implementation details is a (stronger) argument than the
> use of public API (like, technically, InternalCDOView).

I made no such argument. Please forget about the reflective access,
because it's only detracting from the point I'm trying to make.

The point is this: after retrieving the rootResource explicitly by its
CDOID (using view.getObject(rootID)), the rootResource should be present
in the view's objects map.

Prior to the fix for bug 337523, this was not the case. And after applying
Martin's patch for *this* bug, it is again not the case, because this patch
undoes the fix for 337523.

Martin's patch hides the problem by adding a different check at a different
point, which stuffs the rootResource into the map if it's not present. That
makes the test pass, but doesn't change the fact that retrieval of the
rootResource by its ID fails to add the rootResource to the objects map. 
And THAT is the original bug 337523.
Comment 19 Martin Fluegge CLA 2011-05-20 09:53:24 EDT
I committed the Dawn UI test (UI test v1) which reproduces the problem.

Committed revision 7819
Comment 20 Martin Fluegge CLA 2011-05-20 09:55:07 EDT
Since we decided to handle this issue by excluding the root resource from the resource set, I mark this one as duplicate of Bug 346636.

*** This bug has been marked as a duplicate of bug 346636 ***
Comment 21 Martin Fluegge CLA 2011-05-24 14:09:18 EDT
Committed revision 7840:
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.edit
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.editor
Comment 22 Martin Fluegge CLA 2011-05-24 14:09:41 EDT
Committed revision 7841:
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.edit
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.emf.ui
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.gmf
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.gmf.edit
- trunk/plugins/org.eclipse.emf.cdo.dawn.codegen.dawngenmodel.gmf.ui
Comment 23 Martin Fluegge CLA 2011-05-24 14:17:45 EDT
Please ignore the last two comments as the were added by mistake.
Comment 24 Eike Stepper CLA 2012-09-21 06:50:39 EDT
Closing.