Bug 152578

Summary: [prefs] IJavaProject.setOption(Object,Object) wrongly removes key when value is equals to JavaCore one
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: martinae
Version: 3.2   
Target Milestone: 3.4 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Frederic Fusier CLA 2006-08-02 07:27:52 EDT
Follow-up of bug 152562.

JavaProject.setOption(Object,Object) method should remove key only if given value is equals to default one. JavaCore.getOption(optionName) is not the default value but the inherited one.
Comment 1 Martin Aeschlimann CLA 2006-08-02 08:11:56 EDT
With this bug suggestion, for default= "1.1", workspace="1.2", project="1.3"
after 'project.setOption(SETTING1, "1.1")', 'project.getOption(SETTING1)' would result in "1.2"

I think the user expects to read the value he just wrote...
Comment 2 Frederic Fusier CLA 2006-08-02 09:18:48 EDT
You're right, I missed this point!

In fact JavaCore options still behave like org.eclipse.core.runtime.Preferences and not as org.eclipse.core.runtime.preferences.IEclipsePreferences...
As our options rely on IEclipsePreferences since 3.0 it should be good to make them behaving the same.

So, that means that:
1) setOption should never remove any key, just set given value to given key
   (this bug)
2) user should have we should have an API to remove an option
   (bug 15252)

Does it make more sense?
Comment 3 Frederic Fusier CLA 2006-08-02 09:20:33 EDT
I have some problems with bug references... :-(
Previous comment should obviously read bug 152562...
Comment 4 Martin Aeschlimann CLA 2006-08-02 09:27:15 EDT
That makes sense! But as said, I'm not so much for a new API but just using 'null' in setOptions.
Comment 5 Frederic Fusier CLA 2007-05-02 05:31:11 EDT
Unfortunately work on performances didn't let me enough time to finalize a fix for this bug. Not sure if I can put it in 3.3 or if I'd have to defer it to next version...
Comment 6 Frederic Fusier CLA 2007-08-20 10:58:33 EDT
Released for 3.4M2 in HEAD stream.
Comment 7 Maxime Daniel CLA 2007-09-18 04:23:09 EDT
Test case is OptionTests#testBug152578.
Verified for 3.4 M2 using build I20070917-0010.