Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346600 - UpdateReference references the same value on right and left target
Summary: UpdateReference references the same value on right and left target
Status: CLOSED FIXED
Alias: None
Product: EMFCompare
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: EMF Compare CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-20 04:20 EDT by Mikaël Barbero CLA
Modified: 2011-05-23 09:34 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikaël Barbero CLA 2011-05-20 04:20:09 EDT
When setting/unsetting the value of a reference (from null to someting or something to null), the value referenced by the UpdateReference instance are the same. 

It appears that in the ReferencesCheck#createUpdatedReferenceOperation(EObject, EObject, EReference, EObject, EObject), the left/right targets are set to deleted/added values by only testing their nullity. The added/deleted values MUST be checked for nullity before assigning deleted/added values respectively to left/right targets.

Here is the patch:

== before ==

EObject leftTarget = getMatchedEObject(addedValue);
EObject rightTarget = getMatchedEObject(deletedValue);
// checks if target are defined remotely
if (leftTarget == null) {
	leftTarget = deletedValue;
}
if (rightTarget == null) {
	rightTarget = addedValue;
}

== after ==

EObject leftTarget = getMatchedEObject(addedValue);
EObject rightTarget = getMatchedEObject(deletedValue);
// checks if target are defined remotely
if (leftTarget == null && addedValue != null) {
	leftTarget = deletedValue;
}
if (rightTarget == null && deletedValue != null) {
	rightTarget = addedValue;
}
Comment 1 Laurent Goubet CLA 2011-05-23 09:34:44 EDT
Trivial fix commited on HEAD