You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by GMail - Ugo Gagliardelli <ug...@gmail.com> on 2012/03/16 18:42:33 UTC

[configuration] PropertyConverter.to method fails

I'm experiencing a problem while reading an ini file.
My class is mapping ini section values to comfortable values such as 
Integer, InetAddress and so on, when I retrieve a value as a String I 
get a ConversionException. This is tha stack trace:


My code act as:
             DataConfiguration  db = new 
DataConfiguration(getConfig().getSection(sectionName));
where getConfig returns a HierarchicalINIConfiguration object

             Object value =  db.get(keyType, keyName));

where keyType is a Class<?> object and keyName is a String object

When keyType is java.lang.String I have the problem.
Inside PropertyConverter.to(Class<?> cls, Object value, Object[] params) 
there is a long if/else that if argument cls is java.langString doesn't 
match any condition and throws a ConversionException.

Is this figure correct?

Maybe at the very beginning of the to method should be:

if (cls == value.getClass()) return value;
Thank you for the attention

Ugo Gagliardelli

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


Re: [configuration] PropertyConverter.to method fails

Posted by Oliver Heger <ol...@oliver-heger.de>.
Am 19.03.2012 10:45, schrieb GMail Manzoni.Alessandro4:
> il 17.03.2012 18:05, Scrive Oliver Heger 124499136:
>> You are right, this is a bug in PropertyConverter.to(). The trivial or
>> identity conversion should be handled, too. I opened a bug ticket to
>> track this:
>> https://issues.apache.org/jira/browse/CONFIGURATION-487
>>
>> Thanks for the report!
>> Oliver
> [...]
> When 1.9 will be available?
> Download link still refers to 1.8.

1.9 is currently under development. There is no concrete release date 
yet. (We do not have regular release cycles.)

Oliver

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


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


Re: [configuration] PropertyConverter.to method fails

Posted by "GMail Manzoni.Alessandro4" <ma...@gmail.com>.
il 17.03.2012 18:05, Scrive Oliver Heger 124499136:
> You are right, this is a bug in PropertyConverter.to(). The trivial or 
> identity conversion should be handled, too. I opened a bug ticket to 
> track this:
> https://issues.apache.org/jira/browse/CONFIGURATION-487
>
> Thanks for the report!
> Oliver
[...]
When 1.9 will be available?
Download link still refers to 1.8.

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


Re: [configuration] PropertyConverter.to method fails

Posted by Oliver Heger <ol...@oliver-heger.de>.
Am 16.03.2012 18:42, schrieb GMail - Ugo Gagliardelli:
> I'm experiencing a problem while reading an ini file.
> My class is mapping ini section values to comfortable values such as
> Integer, InetAddress and so on, when I retrieve a value as a String I
> get a ConversionException. This is tha stack trace:
>
>
> My code act as:
> DataConfiguration db = new
> DataConfiguration(getConfig().getSection(sectionName));
> where getConfig returns a HierarchicalINIConfiguration object
>
> Object value = db.get(keyType, keyName));
>
> where keyType is a Class<?> object and keyName is a String object
>
> When keyType is java.lang.String I have the problem.
> Inside PropertyConverter.to(Class<?> cls, Object value, Object[] params)
> there is a long if/else that if argument cls is java.langString doesn't
> match any condition and throws a ConversionException.
>
> Is this figure correct?
>
> Maybe at the very beginning of the to method should be:
>
> if (cls == value.getClass()) return value;
> Thank you for the attention

You are right, this is a bug in PropertyConverter.to(). The trivial or 
identity conversion should be handled, too. I opened a bug ticket to 
track this:
https://issues.apache.org/jira/browse/CONFIGURATION-487

Thanks for the report!
Oliver

>
> Ugo Gagliardelli
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>


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