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

Bug 311758

Summary: Removing adapters while closing a view.
Product: [Modeling] EMF Reporter: Michael Szediwy <michael>
Component: cdo.net4jAssignee: Eike Stepper <stepper>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: minor    
Priority: P3    
Version: 3.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Patch for Lifecycle.java none

Description Michael Szediwy CLA 2010-05-05 11:33:14 EDT
Build Identifier: 3.0

When a CDO view gets closed it fires some lifecycle events. I tried to remove an adaper from a CDO object within during the deactivation. It throws an java.lang.IllegalStateException "View closed". Altough it is unnecessary to remove adapters when a view is closing it would be nice not to throw exceptions.

Reproducible: Always

Steps to Reproduce:
1.Open a CDO View and add an adapter to an CDO object.
2.Add a Lifecycle listener to the view and remove the adpater during aboutToDeactivate.
3.Close the view.
Comment 1 Michael Szediwy CLA 2010-05-05 11:33:57 EDT
[ERROR] View closed
java.lang.IllegalStateException: View closed
 at org.eclipse.emf.internal.cdo.util.FSMUtil.adapt(FSMUtil.java:122)
 at org.eclipse.emf.internal.cdo.view.CDOViewImpl$ChangeSubscriptionManager.subscribe(CDOViewImpl.java:2071)
 at org.eclipse.emf.internal.cdo.view.CDOViewImpl$ChangeSubscriptionManager.unsubscribe(CDOViewImpl.java:1959)
 at org.eclipse.emf.internal.cdo.view.CDOViewImpl.unsubscribe(CDOViewImpl.java:1637)
 at org.eclipse.emf.internal.cdo.view.CDOViewImpl.handleRemoveAdapter(CDOViewImpl.java:1618)
 at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didRemove(CDOObjectImpl.java:449)
 at org.eclipse.emf.internal.cdo.CDOObjectImpl$1.didRemove(CDOObjectImpl.java:1)
 at org.eclipse.emf.common.util.BasicEList.remove(BasicEList.java:622)
 at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.remove(BasicNotifierImpl.java:170)
 at org.eclipse.emf.common.util.AbstractEList.remove(AbstractEList.java:466)
 at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.remove(BasicNotifierImpl.java:163)
Comment 2 Eike Stepper CLA 2010-05-09 06:48:04 EDT
Moving to Net4j, see patch for Lifecycle.java
Comment 3 Eike Stepper CLA 2010-05-09 06:48:47 EDT
Created attachment 167623 [details]
Patch for Lifecycle.java

Moving the state transition down in activate() and deactivate()
Comment 4 Eike Stepper CLA 2010-05-09 06:53:04 EDT
Committed to HEAD
Comment 5 Eike Stepper CLA 2010-06-29 04:36:22 EDT
Available in 3.0 GA:
http://download.eclipse.org/modeling/emf/cdo/updates/3.0-releases/