commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <>
Subject Re: [configuration] no exception on missing key
Date Thu, 01 Sep 2005 19:45:27 GMT
Kevin Klinemeier wrote:

>Can one set that flag in the config file or the composite file?  I
>hoped something like this would work, but no luck:
> <!--  the order of prescidence is first-to-last -->
> <system/>
> <xml fileName="prodConfig.xml"
>               optional="true"
>               throwExceptionOnMissing="true"/>
>On a related note, is there some kind of document that describes the
>config options available in that file?  I feel like there's a doc page
>I haven't found yet.
>(initially sent to the wrong list, sorry for the cross-post)
I checked this and found out that there is a bug (or at least an 
undesired behavior) in CompositeConfiguration:

When the included configurations are loaded by the ConfigurationFactory, 
their properties, including the throwExceptionOnMissing flag, are 
correctly set. But when they are added to the resulting 
CompositeConfiguration, this flag is reset because the code looks as 

public void addConfiguration(Configuration config)
  if (config instanceof AbstractConfiguration)

The purpose is that the configurations contained in a 
CompositeConfiguration should have the same exception behavior as the 
composite itself. Unfortunately when loaded from a ConfigurationFactory, 
it is not possible to define the CompositeConfiguration's exception 
flag, so it is always false.

I guess this should be fixed, or at least the 
setThrowExceptionOnMissing() method overloaded in CompositeConfiguration 
to set the flags on the contained configs. Then it would be possible to 
turn this on after it was loaded by the factory.


>Oliver Heger wrote:
>>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!
>To unsubscribe, e-mail:
>For additional commands, e-mail:

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

View raw message