When performing a delete of objects in CDO I'm getting a change notification (via an EContentAdapter) in which the oldValue is of type CDOFeatureDeltaImpl$UnknownValue, and fails to cast to InternalEObject when calling super.notifyChanged() on the adapter.
The code is very simple:
adapter = new EContentAdapter() {
@Override
public void notifyChanged(Notification notification) {
super.notifyChanged(notification); // Error raised here
// Notification code here
}
};
object.eAdapters().add(adapter);
See the stack trace beneath. Since the cast is in plain EMF code and not CDO, it seems that a fix is required elsewhere than where the exception is raised. Could you confirm this is a bug and I'm not missing something? I'm not 100% sure that calling super().notifyChanged is necessary, but it seems the examples I've seen all call it.
java.lang.ClassCastException: class org.eclipse.emf.cdo.internal.common.revision.delta.CDOFeatureDeltaImpl$UnknownValue cannot be cast to class org.eclipse.emf.ecore.InternalEObject (org.eclipse.emf.cdo.internal.common.revision.delta.CDOFeatureDeltaImpl$UnknownValue is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @45376166; org.eclipse.emf.ecore.InternalEObject is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @34bd4349)
at org.eclipse.emf.ecore.util.EContentAdapter.removeAdapter(EContentAdapter.java:420)
at org.eclipse.emf.ecore.util.EContentAdapter.handleContainment(EContentAdapter.java:185)
at org.eclipse.emf.ecore.util.EContentAdapter.selfAdapt(EContentAdapter.java:100)
at org.eclipse.emf.ecore.util.EContentAdapter.notifyChanged(EContentAdapter.java:66)
at com.quanteksystems.test.cdo.ListSelection$2.notifyChanged(ListSelection.java:172)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
at org.eclipse.emf.common.notify.impl.NotificationChainImpl.dispatch(NotificationChainImpl.java:200)
at org.eclipse.emf.common.notify.impl.NotificationChainImpl.dispatch(NotificationChainImpl.java:188)
at org.eclipse.emf.internal.cdo.view.CDOViewImpl.sendDeltaNotifications(CDOViewImpl.java:1395)
at org.eclipse.emf.internal.cdo.view.CDOViewImpl.doInvalidateSynced(CDOViewImpl.java:1279)
at org.eclipse.emf.internal.cdo.view.CDOViewImpl.doInvalidate(CDOViewImpl.java:1216)
at org.eclipse.emf.internal.cdo.view.CDOViewImpl$ViewInvalidation.doRun(CDOViewImpl.java:2861)
at org.eclipse.net4j.util.concurrent.RunnableWithName.run(RunnableWithName.java:29)
at org.eclipse.net4j.util.concurrent.SerializingExecutor.run(SerializingExecutor.java:82)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
As a temporary workaround I've added a check:
if(notification.getOldValue() instanceof UnknownValue)
return;
We are currently on the 4.10 release. Thanks!