Bug 519888 - DialogSettings should not throw Exception if key is not set
Summary: DialogSettings should not throw Exception if key is not set
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 516030
  Show dependency tree
 
Reported: 2017-07-19 09:37 EDT by David Weiser CLA
Modified: 2019-05-30 11:23 EDT (History)
4 users (show)

See Also:
daniel_megert: review-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.