Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 73251 invoked from network); 30 Oct 2008 07:27:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Oct 2008 07:27:36 -0000 Received: (qmail 64062 invoked by uid 500); 30 Oct 2008 07:27:40 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 63987 invoked by uid 500); 30 Oct 2008 07:27:40 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 63976 invoked by uid 99); 30 Oct 2008 07:27:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Oct 2008 00:27:40 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Oct 2008 07:26:33 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 44ECD234C24A for ; Thu, 30 Oct 2008 00:26:44 -0700 (PDT) Message-ID: <795977119.1225351604281.JavaMail.jira@brutus> Date: Thu, 30 Oct 2008 00:26:44 -0700 (PDT) From: "Oliver Heger (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (CONFIGURATION-336) Brackets in property key causes NumberFormatException In-Reply-To: <1412187110.1222674644909.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CONFIGURATION-336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12643769#action_12643769 ] Oliver Heger commented on CONFIGURATION-336: -------------------------------------------- The problem is basically caused by the conversion of a flat Configuration (e.g. a PropertiesConfiguration) into a hierarchical one. Here all keys of the flat configuration are obtained and inserted into the new hierarchical configuration. The hierarchical configuration is initialized with a default expression engine that parses the property keys for brackets and tries to interpret their contents as index values. This fails in this specific case. I think, a good solution for this problem would be to support using a specific ExpressionEngine when converting a flat configuration to a hierarchical one. If the property keys contain some critical characters like brackets, an expression engine could be used that is initialized with different index markers, e.g. square brackets. To implement this solution at least two places have to be changed: * ConfigurationUtils needs an overloaded variant of the convertToHierarchical() method, which also expects an ExpressionEngine as parameter. * CombinedConfiguration should use its own expression engine when converting flat configurations to hierarchical ones. (This makes sense because this expression will also be used when querying the resulting combined configuration.) > Brackets in property key causes NumberFormatException > ----------------------------------------------------- > > Key: CONFIGURATION-336 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-336 > Project: Commons Configuration > Issue Type: Bug > Affects Versions: 1.5 > Reporter: Pavel Savara > > 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(NumberFormatException.java:48) > at java.lang.Integer.parseInt(Integer.java:447) > at java.lang.Integer.parseInt(Integer.java:497) > at org.apache.commons.configuration.tree.DefaultConfigurationKey > $KeyIterator.checkIndex(DefaultConfigurationKey.java:834) > at org.apache.commons.configuration.tree.DefaultConfigurationKey > $KeyIterator.nextKey(DefaultConfigurationKey.java:511) at > org.apache.commons.configuration.tree.DefaultExpressionEngine.findNodesForKey(DefaultExpressionEngine.java:462) at > org.apache.commons.configuration.tree.DefaultExpressionEngine.query(DefaultExpressionEngine.java:286) at > org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(HierarchicalConfiguration.java:925 at > org.apache.commons.configuration.HierarchicalConfiguration.setProperty(HierarchicalConfiguration.java:735) at > org.apache.commons.configuration.ConfigurationUtils.copy(ConfigurationUtils.java:143) at > org.apache.commons.configuration.ConfigurationUtils.convertToHierarchical(ConfigurationUtils.java:199) at org.apache.commons.configuration.CombinedConfiguration > $ConfigData.getTransformedRoot(CombinedConfiguration.java:794) at > org.apache.commons.configuration.CombinedConfiguration.constructCombinedNode(CombinedConfiguration.java:653) at > org.apache.commons.configuration.CombinedConfiguration.getRootNode(CombinedConfiguration.java:504) at > org.apache.commons.configuration.HierarchicalConfiguration.fetchNodeList(HierarchicalConfiguration.java:925) at > org.apache.commons.configuration.HierarchicalConfiguration.getProperty(HierarchicalConfiguration.java:327) at > org.apache.commons.configuration.CombinedConfiguration.getProperty(CombinedConfiguration.java:578) at > org.apache.commons.configuration.AbstractConfiguration.resolveContainerStore(AbstractConfiguration.java:1155) at > org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1034) at > org.apache.commons.configuration.AbstractConfiguration.getString(AbstractConfiguration.java:1017) > 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.