Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340984 - Preferences compatibility Preferences.IPropertyChangeListeners receive event of wrong type via PreferencesForwarder
Summary: Preferences compatibility Preferences.IPropertyChangeListeners receive event ...
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 3.7   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: platform-runtime-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-25 12:58 EDT by James Blackburn CLA
Modified: 2011-03-28 12:19 EDT (History)
1 user (show)

See Also:


Attachments
test 1 (3.29 KB, patch)
2011-03-25 13:00 EDT, James Blackburn CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Blackburn CLA 2011-03-25 12:58:56 EDT
I noticed an issue which looks remarkable similar to:

Bug 55138 - [runtime] prefs: pref change events not backwards compatible

+ A preference listener registered like:

Preferences preferences = ResourcesPlugin.getPlugin().getPluginPreferences();
preferences.addPropertyChangeListener(this);


When a client does:

ResourcesPlugin.getPlugin().getPluginPreferences().setValue(RefreshManager.PREF_LIGHTWEIGHT_AUTO_REFRESH, true);

The event listener receives an event with value type _Boolean_.

When a client uses the new API:
		InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES).putBoolean(RefreshManager.PREF_LIGHTWEIGHT_AUTO_REFRESH, true);

An event is fired with new value of _String_.


Effectively this could break existing plugin preference listeners when clients use the new non-deprecated API.

Test to be attached.
Comment 1 James Blackburn CLA 2011-03-25 13:00:39 EDT
Created attachment 191923 [details]
test 1

Test for the issue.
Comment 2 DJ Houghton CLA 2011-03-28 11:22:56 EDT
Unfortunately this is a known issue. There is a reference here in an old doc:
   http://www.eclipse.org/eclipse/platform-core/documents/user_settings/pref_apis.html

It was a consequence of trying to jump through hoops to maintain backwards compatibility but still move forward. At the time there were 3 APIs that we needed to play nice together. So we determined that it was best to update the old javadoc and move forward with the new API. (which contained un-typed values and was similar to the APIs in OSGi and the JDK)
Comment 3 James Blackburn CLA 2011-03-28 12:19:18 EDT
Ok, thanks.

In the case of the example it would be possible to fire an event of the right type as I'm explicitly doing a typed put:

InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES).putBoolean(RefreshManager.PREF_LIGHTWEIGHT_AUTO_REFRESH, true);

However as it's been this way for so long (and no one else has complained) perhaps I was unlucky in writing code that expected this.