commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <>
Subject Re: [configuration] NoSuchElementException vs null
Date Mon, 21 Jun 2004 10:26:05 GMT
Emmanuel Bourg wrote:

> Well at this point I still haven't solved my main issue: do we want to 
> throw an exception on getList() if the property doesn't exist? My 
> preference is to not throw a NoSuchElementException and return an empty 
> List instead, this will be similar to getStringArray which returns an 
> empty array if the property is missing.

The getList(String) implementation in AbstractConfiguration never throws 
  a NoSuchElementException, I was mislead into thinking this because it 
was coded like this:

List list = getList(key, null);
if (list != null) {
     return list;
} else {
     throw new NoSuchElementException();

but getList(key, null) returns an empty list if the default value is null!

I'll remove the exception from getList(String) and let the null default 
value be returned. getList(String) will return an empty List if the list 
is null.

Emmanuel Bourg

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message