Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337378 - [DataBinding] CompositeMap returns incorrect oldValue in diff
Summary: [DataBinding] CompositeMap returns incorrect oldValue in diff
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact: Matthew Hall CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-16 17:55 EST by Nigel Westbury CLA
Modified: 2013-07-24 10:46 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 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).