Bug 459968 - CDOObjectImpl is broken when not using a CDOResource
Summary: CDOObjectImpl is broken when not using a CDOResource
Status: NEW
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.13   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-15 17:53 EST by Alain Picard CLA
Modified: 2020-12-11 10:36 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alain Picard CLA 2015-02-15 17:53:14 EST
CDOObejctImpl re-implements the method eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID, NotificationChain msgs) from BasicEObjectImpl, but it breaks when the resource is not a CDOResource.

It starts with:
boolean isResourceRoot = this instanceof CDOResource && ((CDOResource)this).isRoot();

and then if this is not a CDOResource, it won't be root and this cause the following code to act incorrectly:
boolean moved = oldView != null && oldView == newView;
if (!moved && oldResource != null && oldResource != newResource && !isResourceRoot) {
  oldResource.detached(this);
}

compared to the original:
 if (oldResource != newResource && oldResource != null) {
  oldResource.detached(this);
}

the solution that we applied is to call super when not dealing with a CDOResource:
if (!(this instanceof CDOResource)) {
 return super.eBasicSetContainer(newContainer, newContainerFeatureID, msgs);
}
boolean isResourceRoot = ((CDOResource)this).isRoot();

and voila, problem solved.
Comment 1 Eike Stepper CLA 2015-07-14 02:22:14 EDT
Moving all open bugzillas to 4.5.
Comment 2 Esteban DUGUEPEROUX CLA 2015-07-15 10:42:59 EDT
Hi Alain,

Could you give more details about the problematic use case this code affect?
With a JUnit test case for example.
Comment 3 Alain Picard CLA 2015-07-15 19:25:46 EDT
Estaban,

I don't have a unit test for it, but the problem occurs when your EObject inherits from CDOObject, like ours do, but you are dealing with a non CDO repository (i.e. a standard EMF XMI repository).

This is a pattern that works very well, but in this case there was a small glitch with this scenario.

HTH
Alain
Comment 4 Eike Stepper CLA 2016-07-31 01:05:08 EDT
Moving all unaddressed bugzillas to 4.6.
Comment 5 Eike Stepper CLA 2017-12-28 01:20:39 EST
Moving all open bugs to 4.7
Comment 6 Eike Stepper CLA 2019-11-08 02:09:00 EST
Moving all unresolved issues to version 4.8-
Comment 7 Eike Stepper CLA 2019-12-13 12:44:09 EST
Moving all unresolved issues to version 4.9
Comment 8 Eike Stepper CLA 2020-12-11 10:36:26 EST
Moving to 4.13.