[ 
https://issues.apache.org/jira/browse/FELIX-3757?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Felix Meschberger reopened FELIX-3757:
--------------------------------------


Since you committed a single patch for three issues, I don't exactly know which 
part of the patch applies to which fix. So I just open this one..

After applying this patch, the OSGi CT fails for the following reasons:

(1) ADValidator.validateNumericValue does value.compareTo(Object) for min and 
max. Both min and max are Integer objects while the value may be any type 
extends Number. If value happens to not be Integer, this comparison fails with 
a ClassCastException.

Example failure:
>   java.lang.ClassCastException: java.lang.Integer cannot be cast to 
> java.lang.Long
>           at java.lang.Long.compareTo(Long.java:50)
>           at 
> org.apache.felix.metatype.ADValidator.validateNumericValue(ADValidator.java:302)

(2) Floating point number validation fails: ADValidator.validateNumericValue 
assumes the min and max values to be Integer values which is wrong. Instead the 
min and max values for numeric attributes is expected to be of the same type as 
the value type. Hence parsing those into an Integer is inherently wrong.

The fix to both issues is to actually parse the min and max values with the 
same parsing as parsing the value to be checked.
                
> MetaType AD.validate() ignored mandatory fields without min, max or 
> optionValues
> --------------------------------------------------------------------------------
>
>                 Key: FELIX-3757
>                 URL: https://issues.apache.org/jira/browse/FELIX-3757
>             Project: Felix
>          Issue Type: Bug
>          Components: Metatype Service
>    Affects Versions:  metatype-1.0.6
>            Reporter: J.W. Janssen
>            Assignee: J.W. Janssen
>             Fix For: metatype-1.0.8
>
>
> If an attribute is required, but does not define its min, max or optionValues 
> parameters, the validate() regards absent data as valid.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to