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

Bug 337378

Summary: [DataBinding] CompositeMap returns incorrect oldValue in diff
Product: [Eclipse Project] Platform Reporter: Nigel Westbury <nigelipse>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: RESOLVED FIXED QA Contact: Matthew Hall <qualidafial>
Severity: normal    
Priority: P3 CC: jpp-mac, prakash
Version: 4.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Nigel Westbury CLA 2011-02-16 17:55:16 EST
Build Identifier: HEAD

There is a bug in CompositeMap that results in the incorrect oldValue being returned in the diff.  You can see the error if you look at the implementation for the firstMapListener.  handleMapChange, the last case where both 'added' and 'removed' are false, you see the following line:

	oldValues.put(changedKey, oldValue);

This is incorrect.  'oldValue' is the oldValue from the first map being a key for the second map. oldValues should contain the values from the second map.  So not only is the value returned as the old value in the diff incorrect, it is not even the right type.


Reproducible: Always

Steps to Reproduce:
If you need a snippet to show the problem I could probably do so but I'm hoping that won't be necessary.
Comment 1 J.-P. Pellet CLA 2012-10-23 07:24:32 EDT
Exactly. That line should simply be replaced by:

    oldValues.put(changedKey, secondMap.get(oldValue));

I have done this (plus added generics) to the org.eclipse.core.databinding.observable plugin on github here:

    https://github.com/jppellet
Comment 2 Nigel Westbury CLA 2013-07-24 10:46:38 EDT
This has been fixed in the e4 databinding bundles.  (the 'E4 Databinding' bundles are avaiable in the e4 repositories, go to http://download.eclipse.org/e4/downloads/ to get a p2 repository link).