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

Bug 361250

Summary: Resource cannot be removed from resource set
Product: [Modeling] EMF Reporter: Egidijus Vaisnora <vaisegid>
Component: cdo.coreAssignee: Victor Roldan Betancort <vroldanbet>
Status: CLOSED WORKSFORME QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 CC: stepper
Version: 4.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 338921    
Bug Blocks:    
Attachments:
Description Flags
Test case none

Description Egidijus Vaisnora CLA 2011-10-18 07:48:42 EDT
Create Resource from CDO transaction, get ResourceSet and remove Resource. This operation fails with following exception:

Caused by: org.eclipse.emf.cdo.common.util.CDOException: Attempt to remove a dirty resource from a resource set: CDOResource@oid2
	at org.eclipse.emf.internal.cdo.view.CDOViewSetImpl.deregisterResources(CDOViewSetImpl.java:302)
	at org.eclipse.emf.internal.cdo.view.CDOViewSetImpl.notifyChanged(CDOViewSetImpl.java:259)
	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.remove(NotifyingListImpl.java:719)
	at org.eclipse.emf.common.util.AbstractEList.remove(AbstractEList.java:466)
	at org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_360767_Test.testResourceRemoteDetachRemovalNotification(Bugzilla_360767_Test.java:43)
	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:597)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at org.eclipse.net4j.util.tests.AbstractOMTest.runBare(AbstractOMTest.java:221)
	at org.eclipse.emf.cdo.tests.config.impl.ConfigTest.runBare(ConfigTest.java:526)
	... 33 more
Comment 1 Egidijus Vaisnora CLA 2011-10-18 07:55:11 EDT
Created attachment 205416 [details]
Test case
Comment 2 Eike Stepper CLA 2011-10-18 12:19:53 EDT
Are you going to provide a test case?
Comment 3 Eike Stepper CLA 2011-10-18 12:20:10 EDT
Argh, ignore my silly question!
Comment 4 Eike Stepper CLA 2011-10-18 12:24:47 EDT
This bug has been introduced with the fix to bug 338921. Assigning to Vik for analysis.
Comment 5 Victor Roldan Betancort CLA 2011-12-15 10:28:06 EST
I believe that exception is expected. Not exactly sure about the reasons why we introduced it, but its probably related with the fact that if you remove a dirty CDOResource (in this case, a it's in state NEW), the underlying CDOTransaction is left dirty, and that may introduce unwanted changes to future commits. Performing rollback automatically is probably not safe, so I guess this exception is indicating "please tidy up your changes before discarding that resource". Eike, do you recall anything about this?

Furthermore, even if that exception didn't raise, yet another would raise, because the resource doesn't exist (the resource is not committed, and neither its part of the ResourceSet, as it has been removed).
So the last 3 lines of code of the test-case would fail anyway. What were you exactly trying to achieve?
Comment 6 Eike Stepper CLA 2011-12-15 11:09:44 EST
I remember now and agree with Vik, this is the expected behaviour.