You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by ru...@grunt.berkeley.edu on 2005/08/24 19:30:25 UTC
[configuration] no exception on missing key
The documentation says that getString() throws a
NoSuchElementException "if the key doesn't map to an existing object."
I'm not getting any exception when I tested this by deleting the key
from my .xml file. For example, in the following, I deleted the whole
<url> line and didn't get an exception when I did a getString("ldap.url").
<?xml version="1.0" encoding="ISO-8859-1" ?>
<config>
<ldap>
<url>ldap://caldir.berkeley.edu:636</url>
<base>ou=people, dc=berkeley, dc=edu</base>
<uid>uid=name, ou=applications, dc=berkeley, dc=edu</uid>
<password>secret</password>
</ldap>
</config>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: [configuration] no exception on missing key
Posted by Oliver Heger <ol...@t-online.de>.
You are right, Moran, setting the throwExceptionOnMissing flag should do
the trick.
However we should rework the javadocs for the Configuration getter
methods. They in fact claim that an exception is always thrown for
missing properties!
Oliver
Moran Ben-David wrote:
>Try checking the value returned by
>
> AbstractConfiguratin.isThrowExceptionOnMissing()
>
>If it is false, then that might explain why you weren't getting an
>exception. Try calling setThrowExceptionOnMissing(true) in that case to get
>the behaviour you're looking for.
>
>Moran
>
>
>
>
>
>>-----Original Message-----
>>From: rusty@grunt.berkeley.edu [mailto:rusty@grunt.berkeley.edu]
>>Sent: Wednesday, August 24, 2005 1:30 PM
>>To: commons-user@jakarta.apache.org
>>Subject: [configuration] no exception on missing key
>>
>>The documentation says that getString() throws a
>>NoSuchElementException "if the key doesn't map to an existing object."
>>I'm not getting any exception when I tested this by deleting the key
>>from my .xml file. For example, in the following, I deleted the whole
>><url> line and didn't get an exception when I did a getString("ldap.url").
>>
>><?xml version="1.0" encoding="ISO-8859-1" ?>
>>
>><config>
>> <ldap>
>> <url>ldap://caldir.berkeley.edu:636</url>
>> <base>ou=people, dc=berkeley, dc=edu</base>
>> <uid>uid=name, ou=applications, dc=berkeley, dc=edu</uid>
>> <password>secret</password>
>> </ldap>
>></config>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
RE: [configuration] no exception on missing key
Posted by Moran Ben-David <mo...@place-base.com>.
Try checking the value returned by
AbstractConfiguratin.isThrowExceptionOnMissing()
If it is false, then that might explain why you weren't getting an
exception. Try calling setThrowExceptionOnMissing(true) in that case to get
the behaviour you're looking for.
Moran
> -----Original Message-----
> From: rusty@grunt.berkeley.edu [mailto:rusty@grunt.berkeley.edu]
> Sent: Wednesday, August 24, 2005 1:30 PM
> To: commons-user@jakarta.apache.org
> Subject: [configuration] no exception on missing key
>
> The documentation says that getString() throws a
> NoSuchElementException "if the key doesn't map to an existing object."
> I'm not getting any exception when I tested this by deleting the key
> from my .xml file. For example, in the following, I deleted the whole
> <url> line and didn't get an exception when I did a getString("ldap.url").
>
> <?xml version="1.0" encoding="ISO-8859-1" ?>
>
> <config>
> <ldap>
> <url>ldap://caldir.berkeley.edu:636</url>
> <base>ou=people, dc=berkeley, dc=edu</base>
> <uid>uid=name, ou=applications, dc=berkeley, dc=edu</uid>
> <password>secret</password>
> </ldap>
> </config>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org