Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323308 - Legacy wrapper fails on detaching objects with opposite references
Summary: Legacy wrapper fails on detaching objects with opposite references
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.legacy (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Martin Fluegge CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-21 15:25 EDT by Martin Fluegge CLA
Modified: 2012-06-19 07:08 EDT (History)
0 users

See Also:
stepper: review+


Attachments
Patch v1 (1.48 KB, patch)
2010-08-27 06:24 EDT, Martin Fluegge CLA
no flags Details | Diff
Test v1 (2.19 KB, patch)
2010-08-27 06:27 EDT, Martin Fluegge CLA
no flags Details | Diff
Patch v2 (1.76 KB, patch)
2010-10-31 12:56 EDT, Martin Fluegge CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Fluegge CLA 2010-08-21 15:25:19 EDT
When detaching objects the legacy wrapper need to adjust the opposite reference. Looking at the attached exception it seems that it does not do this carefully enough.

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.RangeCheck(ArrayList.java:546)
	at java.util.ArrayList.set(ArrayList.java:337)
	at org.eclipse.emf.cdo.spi.common.revision.BaseCDORevision.set(BaseCDORevision.java:484)
	at org.eclipse.emf.internal.cdo.CDOStore.set(CDOStore.java:345)
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper.setOppositeReference(CDOLegacyWrapper.java:232)
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper.cdoInternalPostDetach(CDOLegacyWrapper.java:215)
	at org.eclipse.emf.internal.cdo.CDOStateMachine.detach(CDOStateMachine.java:280)
	at org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.detached(CDOResourceImpl.java:838)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eBasicSetContainer(BasicEObjectImpl.java:1334)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseRemove(BasicEObjectImpl.java:1451)
	at org.eclipse.emf.ecore.util.EcoreEList.inverseRemove(EcoreEList.java:328)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.remove(NotifyingListImpl.java:716)
	at org.eclipse.emf.common.util.AbstractEList.remove(AbstractEList.java:466)
	at org.eclipse.gmf.runtime.notation.impl.DiagramImpl.removeEdge(DiagramImpl.java:600)
	at org.eclipse.emf.cdo.dawn.tests.ui.MultipleResourcesTest.testDeleteAssociationConnectionRemotely(MultipleResourcesTest.java:550)
	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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner.run(SWTBotJunit4ClassRunner.java:54)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64)
	at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117)
	at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:71)
	at java.lang.Thread.run(Thread.java:595)
Comment 1 Martin Fluegge CLA 2010-08-27 06:24:05 EDT
Created attachment 177602 [details]
Patch v1

Unfortunately I could not reproduce this neither with a CDO test model nor on the Dawn test case where it originally occurred. 
The attached patch fixed the problem but since it does not occur anymore I'd like to keep it just as future reference for the case the exception occurs again.
Comment 2 Martin Fluegge CLA 2010-08-27 06:27:04 EDT
Created attachment 177603 [details]
Test v1

Also for future reference I attach the a test (even if it currently could not reproduce the problem)
Comment 3 Martin Fluegge CLA 2010-10-10 03:53:43 EDT
Seems that the problem still exists, see:

http://www.eclipse.org/forums/index.php?t=tree&th=175283&S=4b5956275945654574dfe32e04286e32#page_top

The patch seems to solve it but I still can not reproduce it reliably. We could commit the patch but I actually would postpone this until I have time to reproduce this problem.

Opinions about this?
Comment 4 Martin Fluegge CLA 2010-10-31 12:56:19 EDT
Created attachment 182118 [details]
Patch v2

Patch was out of date. I updated it. Please review.
Comment 5 Martin Fluegge CLA 2010-11-09 13:07:56 EST
Committed to HEAD.
Comment 6 Eike Stepper CLA 2011-06-23 03:39:08 EDT
Available in R20110608-1407