commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oliver Heger (JIRA)" <j...@apache.org>
Subject [jira] Commented: (CONFIGURATION-214) Adding an integer and getting it as a long causes an exception
Date Sat, 27 May 2006 14:57:30 GMT
    [ http://issues.apache.org/jira/browse/CONFIGURATION-214?page=comments#action_12413585
] 

Oliver Heger commented on CONFIGURATION-214:
--------------------------------------------

I agree with you that this is a bug. Coversions between the Number types should be possible.
Will have al look.

> 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
>     Priority: Minor

>
> 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message