commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: [configuration] PropertyConverter.to method fails
Date Sat, 17 Mar 2012 17:05:05 GMT
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


Mime
View raw message