You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Sebastiano Vigna (JIRA)" <ji...@apache.org> on 2006/05/26 16:36:30 UTC

[jira] Created: (CONFIGURATION-214) Adding an integer and getting it as a long causes an exception

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


[jira] Updated: (CONFIGURATION-214) Adding an integer and getting it as a long causes an exception

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/CONFIGURATION-214?page=all ]

Oliver Heger updated CONFIGURATION-214:
---------------------------------------

    Assign To: Oliver Heger

> 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

>
> 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


[jira] Commented: (CONFIGURATION-214) Adding an integer and getting it as a long causes an exception

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
    [ 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


[jira] Resolved: (CONFIGURATION-214) Adding an integer and getting it as a long causes an exception

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


[jira] Updated: (CONFIGURATION-214) Adding an integer and getting it as a long causes an exception

Posted by "Oliver Heger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CONFIGURATION-214?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Heger updated CONFIGURATION-214:
---------------------------------------

    Fix Version/s:     (was: Nightly Builds)
                   1.3

> Adding an integer and getting it as a long causes an exception
> --------------------------------------------------------------
>
>                 Key: CONFIGURATION-214
>                 URL: https://issues.apache.org/jira/browse/CONFIGURATION-214
>             Project: Commons Configuration
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Linux, java 1.5
>            Reporter: Sebastiano Vigna
>         Assigned To: Oliver Heger
>            Priority: Minor
>             Fix For: 1.3
>
>
> 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.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org