Curiosity question I am seeing the ConfigurationConverter behave 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)

It seems for some reason since I used an int, the ConfigurationConverter wants to treat the property as a list. However since I actually put an integer into the property it errors out since it can not convert a integer to a list.

This behavior seems odd.  Why does it do this?

Mike Power

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to