Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 399279 - Cannot remove CDOViewSet from ResourceSet's adapter list
Summary: Cannot remove CDOViewSet from ResourceSet's adapter list
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.2   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Christian Damus CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 290952
  Show dependency tree
 
Reported: 2013-01-28 11:21 EST by Christian Damus CLA
Modified: 2013-06-27 03:32 EDT (History)
1 user (show)

See Also:
stepper: review+


Attachments
Patch for code review (7.69 KB, patch)
2013-01-28 11:28 EST, Christian Damus CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Damus CLA 2013-01-28 11:21:14 EST
Applications that work with UML have to be very careful about cleaning up a ResourceSet when they have finished with it, because UML's singleton CacheAdapter otherwise retains the entire contents of the resource set in memory indefinitely.

As such, it is common practice to do the following:

1. Unload all resources in the resource set (this clears the adapter
   list of every model object).
2. Clear the adapter list of every resource in the resource set.
2. Clear the resource set's resources list.
3. Clear the adapter list of the resource set.

This ensures that the CacheAdapter and any other adapters are all purged and that the CacheAdapter, in particular, won't leak anything.

However, doing this with a resource set that was used for a CDO view results in an IllegalArgumentException because the CDOViewSetImpl.setTarget() method asserts that the new target is a ResourceSet, but null isn't a ResourceSet.

It should be safe to disconnect a CDOViewSet from its ResourceSet when

  * all resources are unloaded and removed from the resource set
  * all associated views are closed and removed from the view set
Comment 1 Christian Damus CLA 2013-01-28 11:28:09 EST
Created attachment 226210 [details]
Patch for code review

Attached a patch that includes JUnit tests and a fix, implementing my suggestion of allowing the resource set to be unlinked if and only if the resource set has no resources and the view set has no views.  It is up to applications to ensure this requirement, but so far my integration of CDO into Papyrus did that fairly naturally.
Comment 2 Christian Damus CLA 2013-01-28 12:33:31 EST
Adding Papyrus CDO umbrella enhancement as a dependent.
Comment 3 Christian Damus CLA 2013-01-30 09:52:33 EST
When is the commit freeze for M5?  It would be nice to get this change in for M5, so that Papyrus can pick it up.

Otherwise, I do have a hack that I can use in Papyrus to block attempts to remove the CDOViewSet from the ResourceSet's adapter list ...
Comment 4 Eike Stepper CLA 2013-02-05 06:08:07 EST
Changing to 4.2, given that you asked for M5 ;-)
Comment 5 Eike Stepper CLA 2013-02-05 06:38:55 EST
I've committed the change for you:

commit 12b83fb6876204888f5de840e2e9b2a13fe56d6e
Comment 6 Eike Stepper CLA 2013-02-05 06:43:16 EST
(In reply to comment #3)
> When is the commit freeze for M5?  

We're a small team and focus on productivity and efficiency - we don't have commit freezes :P

The +2 day is usually the last chance to get something in, if it's trivial or has been reviewed/tested before.
Comment 7 Eike Stepper CLA 2013-06-27 03:32:26 EDT
Available in R20130613-1157 (4.2)