You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Mark Diggory <md...@gmail.com> on 2006/09/11 22:04:48 UTC
[Configuration] Configuration throws no exceptions...
Hello Friends,
I notice that the code for AbstractConfiguration eats exceptions that
the javadoc claims it should throw.
http://jakarta.apache.org/commons/configuration/xref/org/apache/
commons/configuration/AbstractConfiguration.html#692
> /***
> 690 * {@inheritDoc}
> 691 */
> 692 public Integer getInteger(String key, Integer defaultValue)
> 693 {
> 694 Object value = resolveContainerStore(key);
> 695
> 696 if (value == null)
> 697 {
> 698 return defaultValue;
> 699 }
> 700 else
> 701 {
> 702 try
> 703 {
> 704 return PropertyConverter.toInteger(interpolate
> (value));
> 705 }
> 706 catch (ConversionException e)
> 707 {
> 708 throw new ConversionException('\'' + key + "'
> doesn't map to an Integer object", e);
> 709 }
> 710 }
> 711 }
How is it that this can compile when the method signature clearly
doesn't shoe "throws ConfigurationException" ? I thought, maybe its
an extension of RuntimeException, but it doesn't appear so.
Cheers,
Mark
Mark R. Diggory
~~~~~~~~~~~~~
DSpace Systems Manager
MIT Libraries, Systems and Technology Services
Massachusetts Institute of Technology
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [Configuration] Configuration throws no exceptions...
Posted by Mark Diggory <md...@gmail.com>.
On Sep 11, 2006, at 4:18 PM, Oliver Heger wrote:
> Mark Diggory wrote:
>> Hello Friends,
>> I notice that the code for AbstractConfiguration eats exceptions
>> that the javadoc claims it should throw.
>> http://jakarta.apache.org/commons/configuration/xref/org/apache/
>> commons/configuration/AbstractConfiguration.html#692
>>> /***
>>> 690 * {@inheritDoc}
>>> 691 */
>>> 692 public Integer getInteger(String key, Integer defaultValue)
>>> 693 {
>>> 694 Object value = resolveContainerStore(key);
>>> 695
>>> 696 if (value == null)
>>> 697 {
>>> 698 return defaultValue;
>>> 699 }
>>> 700 else
>>> 701 {
>>> 702 try
>>> 703 {
>>> 704 return PropertyConverter.toInteger(interpolate
>>> (value));
>>> 705 }
>>> 706 catch (ConversionException e)
>>> 707 {
>>> 708 throw new ConversionException('\'' + key + "'
>>> doesn't map to an Integer object", e);
>>> 709 }
>>> 710 }
>>> 711 }
>> How is it that this can compile when the method signature clearly
>> doesn't shoe "throws ConfigurationException" ? I thought, maybe
>> its an extension of RuntimeException, but it doesn't appear so.
>> Cheers,
>> Mark
> ConversionException extends ConfigurationRuntimeException, which
> extends the runtime exception NestableRuntimeException (from the
> [lang] project). So it is indeed a runtime exception.
>
> The exception is not eaten, but a more specific message is added.
>
> Oliver
Of course, your very right, I was confusing ConversionException with
ConfigurationException and banging my head against the wall as to why
I couldn't catch it without a compilation error, duh! Thanks for
answering such a foolish question. ;-)
-Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
Re: [Configuration] Configuration throws no exceptions...
Posted by Oliver Heger <ol...@oliver-heger.de>.
Mark Diggory wrote:
> Hello Friends,
>
> I notice that the code for AbstractConfiguration eats exceptions that
> the javadoc claims it should throw.
>
> http://jakarta.apache.org/commons/configuration/xref/org/apache/commons/configuration/AbstractConfiguration.html#692
>
>
>> /***
>> 690 * {@inheritDoc}
>> 691 */
>> 692 public Integer getInteger(String key, Integer defaultValue)
>> 693 {
>> 694 Object value = resolveContainerStore(key);
>> 695
>> 696 if (value == null)
>> 697 {
>> 698 return defaultValue;
>> 699 }
>> 700 else
>> 701 {
>> 702 try
>> 703 {
>> 704 return
>> PropertyConverter.toInteger(interpolate(value));
>> 705 }
>> 706 catch (ConversionException e)
>> 707 {
>> 708 throw new ConversionException('\'' + key + "'
>> doesn't map to an Integer object", e);
>> 709 }
>> 710 }
>> 711 }
>
> How is it that this can compile when the method signature clearly
> doesn't shoe "throws ConfigurationException" ? I thought, maybe its an
> extension of RuntimeException, but it doesn't appear so.
>
> Cheers,
> Mark
>
ConversionException extends ConfigurationRuntimeException, which extends
the runtime exception NestableRuntimeException (from the [lang]
project). So it is indeed a runtime exception.
The exception is not eaten, but a more specific message is added.
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org