commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <>
Subject [jira] Resolved: (CONFIGURATION-336) Brackets in property key causes NumberFormatException
Date Tue, 04 Nov 2008 21:20:44 GMT


Oliver Heger resolved CONFIGURATION-336.

       Resolution: Fixed
    Fix Version/s: 1.6

It is now possible to specify an expression engine when converting a flat configuration to
a hierarchical one. By using a properly configured expression engine you can work around the
problem with property keys having a special meaning for the expression engine.

The applied fix contains two major changes:
* There is an overloaded version of {{ConfigurationUtils.convertToHierarchical()}} that also
expects an {{ExpressionEngine}} as argument.
* {{CombinedConfiguration}} has the new {{conversionExpressionEngine}} property. The {{ExpressionEngine}}
set here is used when the internal node structure is constructed.

In the unit test class for {{CombinedConfiguration}} a new test case was added ({{testConversionExpressionEngine()}}
demonstrating how this new property can be used.

> Brackets in property key causes NumberFormatException
> -----------------------------------------------------
>                 Key: CONFIGURATION-336
>                 URL:
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.5
>            Reporter: Pavel Savara
>            Assignee: Oliver Heger
>             Fix For: 1.6
> Hi,
> When using brackets in property key we get an exception every time.
> Escaping brackets with \ doesn't help.
> Example
> #property in property file
> test(ef)=false
> causes 
> java.lang.NumberFormatException: For input string: "ef" at
> java.lang.NumberFormatException.forInputString(
>         at java.lang.Integer.parseInt(
>         at java.lang.Integer.parseInt(
>         at org.apache.commons.configuration.tree.DefaultConfigurationKey
> $KeyIterator.checkIndex(
>         at org.apache.commons.configuration.tree.DefaultConfigurationKey
> $KeyIterator.nextKey( at
> org.apache.commons.configuration.tree.DefaultExpressionEngine.findNodesForKey(
> org.apache.commons.configuration.tree.DefaultExpressionEngine.query(
> org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(
> org.apache.commons.configuration.HierarchicalConfiguration.setProperty(
> org.apache.commons.configuration.ConfigurationUtils.copy(
> org.apache.commons.configuration.ConfigurationUtils.convertToHierarchical(
 at org.apache.commons.configuration.CombinedConfiguration
> $ConfigData.getTransformedRoot(  at
> org.apache.commons.configuration.CombinedConfiguration.constructCombinedNode(
> org.apache.commons.configuration.CombinedConfiguration.getRootNode(
> org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(
> org.apache.commons.configuration.HierarchicalConfiguration.getProperty(
> org.apache.commons.configuration.CombinedConfiguration.getProperty(
> org.apache.commons.configuration.AbstractConfiguration.resolveContainerStore(
> org.apache.commons.configuration.AbstractConfiguration.getString(
> org.apache.commons.configuration.AbstractConfiguration.getString(

> Explanation i got in mailing list from Oliver Heger
> I guess you use DefaultConfigurationBuilder for loading a combined 
> configuration?
> The exception is due to the fact that brackets have a special meaning in 
> the query syntax for hierarchical configurations. 
> (DefaultConfigurationBuilder transforms all configuration sources into 
> hierarchical configurations, so also for properties, which are not 
> hierarchical by default, the same rules apply.)
> So far escaping brackets or other specific characters in property keys 
> is not supported. It seems to be rather unusual to use brackets in 
> property keys, so you may well be the first one who noticed this problem.
> Unfortunately I don't have a working solution for this problem right 
> now.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message