[ http://issues.apache.org/jira/browse/CONFIGURATION-214?page=all ] Oliver Heger resolved CONFIGURATION-214: ----------------------------------------
Fix Version: Nightly Builds Resolution: Fixed Conversion features between different Number types were added. > Adding an integer and getting it as a long causes an exception > -------------------------------------------------------------- > > Key: CONFIGURATION-214 > URL: http://issues.apache.org/jira/browse/CONFIGURATION-214 > Project: Commons Configuration > Type: Bug > Versions: 1.2 Final > Environment: Linux, java 1.5 > Reporter: Sebastiano Vigna > Assignee: Oliver Heger > Priority: Minor > Fix For: Nightly Builds > > Try this in a BeanShell: > bsh % p = new org.apache.commons.configuration.PropertiesConfiguration(); > bsh % p.setProperty("foo", 6); > bsh % p.getLong("foo"); > // Error: // Uncaught Exception: Method Invocation p.getLong : at Line: 3 : > in file: <unknown file> : p .getLong ( "foo" ) > Target exception: org.apache.commons.configuration.ConversionException: 'foo' > doesn't map to a Long object > org.apache.commons.configuration.ConversionException: 'foo' doesn't map to a > Long object > at > org.apache.commons.configuration.AbstractConfiguration.getLong(AbstractConfiguration.java:667) > The problem is that when an object in a property is not a Long, the only > attempt of PropertyConverter.toLong() is that of treating it as a string. It > could try to convert it to a Number first and then try to convert it to a > long. It is a very confusing behaviour, because if you save and reload the > properties everything works fine (as now the integer is a string). -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]