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

Bug 340984

Summary: Preferences compatibility Preferences.IPropertyChangeListeners receive event of wrong type via PreferencesForwarder
Product: [Eclipse Project] Platform Reporter: James Blackburn <jamesblackburn+eclipse>
Component: RuntimeAssignee: platform-runtime-inbox <platform-runtime-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: major    
Priority: P3 CC: dj.houghton
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
test 1 none

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.