Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 20255 invoked from network); 7 Feb 2011 21:08:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Feb 2011 21:08:19 -0000 Received: (qmail 77134 invoked by uid 500); 7 Feb 2011 21:08:19 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 77067 invoked by uid 500); 7 Feb 2011 21:08:18 -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 77055 invoked by uid 99); 7 Feb 2011 21:08:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Feb 2011 21:08:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Feb 2011 21:08:17 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 7D52C198B75 for ; Mon, 7 Feb 2011 21:07:57 +0000 (UTC) Date: Mon, 7 Feb 2011 21:07:57 +0000 (UTC) From: "Oliver Heger (JIRA)" To: issues@commons.apache.org Message-ID: <1710302352.709.1297112877509.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1444457312.4147.1296606268976.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] Resolved: (CONFIGURATION-432) ConfugrationConverter treats properties different by type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CONFIGURATION-432?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Oliver Heger resolved CONFIGURATION-432. ---------------------------------------- Resolution: Fixed Fix Version/s: 1.7 A fix was applied in subversion, revision 1068130. AbstractConfiguration now has a protected method {{isScalarValue()}} which is called by {{getList()}} and {{getStringArray()}}. If this method returns *true*, a list (or an array) with a single element is created with the value transformed to a string. {{isScalarValue()}} currently accepts the wrapper types for the primitive data types (e.g. Integer, Double, etc.). If other objects should be treated in the same way, the method can be overridden in a subclass. A test case was added for {{ConfigurationConverter}} to verify that the changes on {{getList()}} solve the problem reported in this issue. > ConfugrationConverter treats properties different by type > --------------------------------------------------------- > > Key: CONFIGURATION-432 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-432 > Project: Commons Configuration > Issue Type: Bug > Components: Type conversion > Affects Versions: 1.6 > Environment: Linux Ubuntu > Reporter: Mike Power > Assignee: Oliver Heger > Fix For: 1.7 > > > The ConfigurationConverter is behaving differently depending on if I added an int or a string to a configuration object. > Consider the following code: > 01 Configuration confInt = new BaseConfiguration(); > 02 Configuration confString = new BaseConfiguration(); > 03 confInt.setProperty("port", 80); > 04 confString.setProperty("port", "80"); > 05 assertEquals(80, confInt.getInt("port")); > 06 assertEquals(80, confString.getInt("port")); > 07 > 08 Properties propString = ConfigurationConverter.getProperties(confString); > 09 assertEquals("80", propString.getProperty("port")); > 10 > 11 Properties propInt = ConfigurationConverter.getProperties(confInt); > 12 > 13 assertEquals("80", propInt.getProperty("port")); > As you can see the code is basically duplicated one set uses an int the other set uses a String. However an exception blows out of line 11. > 'port' doesn't map to a List object: 80, a java.lang.Integer > org.apache.commons.configuration.ConversionException: 'port' doesn't map to a List object: 80, a java.lang.Integer > at org.apache.commons.configuration.AbstractConfiguration.getList(AbstractConfiguration.java:1144) > at org.apache.commons.configuration.AbstractConfiguration.getList(AbstractConfiguration.java:1109) > at org.apache.commons.configuration.ConfigurationConverter.getProperties(ConfigurationConverter.java:116) > I interpreted the interface to mean that everything up to and include line 13 would pass. -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira