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

Bug 323806

Summary: LegacyObjectWrapper fails with IllegalStateException while Notifiers are called
Product: [Modeling] EMF Reporter: Martin Fluegge <martin.fluegge>
Component: cdo.legacyAssignee: Martin Fluegge <martin.fluegge>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 Flags: stepper: review+
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch v1 none

Description Martin Fluegge CLA 2010-08-27 06:51:48 EDT
When originally designing the isSet handling on legacy I thought it would be a good idea to check whether the state of the internal instance and the store of the store is the same and throw an exception if not. In this case potential error in the wrapper could have been detected. 

I was never sure that this is true in every case and now it turns out that this could be a problem e.g. when working with ECrossreferenceAdapters and containment references. 

java.lang.IllegalStateException: Store isSet should never differ from instance
	at org.eclipse.emf.internal.cdo.CDOObjectWrapper.eIsSet(CDOObjectWrapper.java:364)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.getInverseReferences(CrossReferenceAdapter.java:902)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.getInverseReferences(ECrossReferenceAdapter.java:311)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.updateImportsAndExports(CrossReferenceAdapter.java:302)
	at org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter.handleContainment(CrossReferenceAdapter.java:211)
	at org.eclipse.emf.ecore.util.ECrossReferenceAdapter.selfAdapt(ECrossReferenceAdapter.java:448)
	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.internal.cdo.CDOObjectWrapper.eNotify(CDOObjectWrapper.java:382)
	at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1033)
	at org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch(NotificationImpl.java:1038)
	at org.eclipse.emf.internal.cdo.view.CDOViewImpl.sendDeltaNotifications(CDOViewImpl.java:1663)
	at org.eclipse.emf.internal.cdo.view.CDOViewImpl.invalidate(CDOViewImpl.java:1496)
	at org.eclipse.emf.internal.cdo.session.CDOSessionImpl$InvalidationRunnable.run(CDOSessionImpl.java:1275)
	at org.eclipse.net4j.util.concurrent.QueueRunner.work(QueueRunner.java:26)
	at org.eclipse.net4j.util.concurrent.QueueRunner.work(QueueRunner.java:1)
	at org.eclipse.net4j.util.concurrent.QueueWorker.work(QueueWorker.java:75)
	at org.eclipse.net4j.util.concurrent.Worker$WorkerThread.run(Worker.java:188)
Comment 1 Martin Fluegge CLA 2010-08-27 07:16:55 EDT
Created attachment 177606 [details]
Patch v1

I had a closer look at it and it seems that the problem occurs if objects are handled in a containment chain. Which means if object A contains B and B contains C all these objects will be touched while selfAdadpt is called for A on a CrossreferenceAdapter. But at this time the LegacyWrapper only could have adjusted A and it's Containment B. But not B's containment. So C's isset state is not yet aligned with the store and the exception occurs. Tha's why I would like to remove the check.

Eike, what do you think about it?
Comment 2 Eike Stepper CLA 2010-08-31 00:54:46 EDT
I've never used a crossreference adapter. Please contact me via Skype to tell me about it.
Comment 3 Martin Fluegge CLA 2010-09-01 16:35:43 EDT
After discussion patch v1 was committed to HEAD.
Comment 4 Eike Stepper CLA 2011-06-23 03:41:00 EDT
Available in R20110608-1407