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

Bug 519888

Summary: DialogSettings should not throw Exception if key is not set
Product: [Eclipse Project] Platform Reporter: David Weiser <david.eclipse000>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, david.eclipse000, loskutov, tom.schindl
Version: 4.8Flags: daniel_megert: review-
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/101550
Whiteboard:
Bug Depends on:    
Bug Blocks: 516030    

Description David Weiser CLA 2017-07-19 09:37:29 EDT
DialogSettings throw an Exception, if getInt(key) is called with a key for which no value was set. Requesting a value with get(key) only returns null and does not throw an Exception. Maybe we could set a default value for getInt(key) etc.?!
Comment 1 Andrey Loskutov CLA 2017-07-19 09:44:06 EDT
You can't change the API contract, and independently of the value you will choose it will break someone using exact this value for some obscure reason :-)

The API is not user friendly, true. If it would just return Integer, it would be enough.

Now one option could be to provide hasValue(String), but this would NOT guarantee that the value is a valid number in the case of int/long.
Comment 2 Thomas Schindl CLA 2017-07-19 09:45:50 EDT
I'd vote for get(String key,int def)
Comment 3 Thomas Schindl CLA 2017-07-19 09:46:17 EDT
sorry getInt(String key, int def)
Comment 4 Andrey Loskutov CLA 2017-07-19 09:51:26 EDT
(In reply to Thomas Schindl from comment #3)
> sorry getInt(String key, int def)

Of course, I'm so stupid!

and getLong(String key, long def) then please, and both in IDialogSettings.
Comment 5 Eclipse Genie CLA 2017-07-19 11:06:01 EDT
New Gerrit change created: https://git.eclipse.org/r/101550
Comment 6 David Weiser CLA 2017-07-19 11:13:38 EDT
Thanks for your quick responses. I pushed a change which adds several methods that takes a default value.

Should I annotate them with @since? And can I annote the other (old) methods as deprecated?
Comment 7 Andrey Loskutov CLA 2017-07-19 11:17:13 EDT
(In reply to David Weiser from comment #6)
> Thanks for your quick responses. I pushed a change which adds several
> methods that takes a default value.
> 
> Should I annotate them with @since? 

Please install API tools and please set API baseline to 4.7. You will see what they report and they offer solutions for errors.

> And can I annote the other (old) methods
> as deprecated?

Depreciation should be announced and also handled by a dedicated bug.
Comment 8 Dani Megert CLA 2019-05-30 11:23:49 EDT
Sorry, I don't think this is worth it.