commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 34098] - [configuration] Inconsistent handling for keys that don't exist
Date Mon, 21 Mar 2005 13:12:17 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34098>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34098





------- Additional Comments From ebourg@apache.org  2005-03-21 14:12 -------
(In reply to comment #0)
> The getXXX(String key) methods in AbstractConfiguration are not consistent in 
> how they handle non-existing keys:
> getProperty(String key) - returns null

getProperty() provides a direct access to the real object stored in the
configuration, it's similar to the get() method of the Map interface and should
not be affected by the throwExceptionOnMissing flag. If you really need this
feature we could add a getObject(String) method throwing an exception when the
key doesn't exist.

> getString(String key) - throws an exception if isThrowExceptionOnMissing is true
> getShort(String key) - throws an exception

getShort() returns a primitive value, we can't return a default value here even
if the throwExceptionOnMissing flag is not set.

> getStringArray(String key) - returns an empty array (why not null?)

Well, why null ? :) An empty array or list is more convenient, you don't have to
check if the value returned is null before using it. Changing the behaviour of
the getXXXArray/List methods when the throwExceptionOnMissing flag is set seems
to make sense.

> I suggest that all these methods (include getProperty()) will check 
> isThrowExceptionOnMissing and if true, throw an exception.

> As it is, it makes it hard to extend this class, and use Configuration in 
> general.

Do you have a specific use case in mind showing how you are affected by this issue ?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message