You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Oliver Heger (JIRA)" <ji...@apache.org> on 2011/02/05 21:00:30 UTC
[jira] Commented: (CONFIGURATION-432) ConfugrationConverter treats
properties different by type
[ https://issues.apache.org/jira/browse/CONFIGURATION-432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12991045#comment-12991045 ]
Oliver Heger commented on CONFIGURATION-432:
--------------------------------------------
The problem actually lies in the {{AbstractConfiguration.getList()}} method which is called by {{ConfigurationConverter}}. Here Strings are treated in a special way while other data types cause the exception menationend in this report. The method {{getStringArray()}} behaves analogously.
> 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
>
> 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