Bug 520697 - CDONotificationBuilder does not properly dispatch container feature notifications
Summary: CDONotificationBuilder does not properly dispatch container feature notificat...
Status: NEW
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.13   Edit
Hardware: PC Windows 10
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-08 11:20 EDT by SWT CLA
Modified: 2020-12-11 10:39 EST (History)
1 user (show)

See Also:


Attachments
Junit test case (38.93 KB, application/x-zip-compressed)
2017-08-11 08:07 EDT, SWT CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description SWT CLA 2017-08-08 11:20:57 EDT
In CDONotificationBuilder#visit(CDOContainerFeatureDelta), line 254 :
http://git.eclipse.org/c/cdo/cdo.git/tree/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDONotificationBuilder.java#n254

The feature parameter seems wrong : EcorePackage.eINSTANCE.eContainmentFeature() returns null.

The notification with a null feature doesn't get to adapters which needs to react to changes on an object's container (using a container EReference).

I think a fix should be something like :

add(new CDODeltaNotificationImpl(object, Notification.SET, object.eClass().getEStructuralFeature(object.eContainerFeatureID()), oldValue, delta.getContainerID()));


Steps to reproduce :

1) Get a CDO ecore model which defines an EClass with a container EReference.

2) Override generated code to add an adapter in the constructor of the EClass implementation :

eAdapters().add(new AdapterImpl() {
  @Override
  public void notifyChanged(Notification msg) {
    System.err.println("## " + msg.getFeature());
    System.err.println("--- " + msg.getOldValue());
    System.err.println("+++ " + msg.getNewValue());
  }
});

3) Activate cdo load notifications using :
cdoView.options().setLoadNotificationEnabled(true);

4) Load an object (of the right EClass) from the CDO repository. For instance :
cdoView.getObject(myObjectId)

The notification of the container feature does not get to the adapter.
If you debug, you'll see the notification in the notification chain, but with an associated "null" feature.

I can't find any easy workaround for this issue. Please let me know if you have one.
Comment 1 SWT CLA 2017-08-11 08:07:18 EDT
Created attachment 269802 [details]
Junit test case

Thanks to Jean-Francois Brazeau (in bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=517168), I could easily re-use his code to create a JUnit test that reproduce the problem.

There's a little mistake in the original description : the notification is properly dispatched to the adapters, but it has a null EStructuralFeature (instead of the container feature).
Comment 2 Eike Stepper CLA 2017-12-28 01:19:09 EST
Moving all open bugs to 4.7
Comment 3 Eike Stepper CLA 2019-11-08 02:06:21 EST
Moving all unresolved issues to version 4.8-
Comment 4 Eike Stepper CLA 2019-12-13 12:46:29 EST
Moving all unresolved issues to version 4.9
Comment 5 Eike Stepper CLA 2020-12-11 10:39:15 EST
Moving to 4.13.