You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2015/04/23 12:15:38 UTC

[jira] [Closed] (FELIX-4665) Metatype service does not allow a default empty string in XML resource

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

Carsten Ziegeler closed FELIX-4665.
-----------------------------------

> Metatype service does not allow a default empty string in XML resource
> ----------------------------------------------------------------------
>
>                 Key: FELIX-4665
>                 URL: https://issues.apache.org/jira/browse/FELIX-4665
>             Project: Felix
>          Issue Type: Bug
>          Components: Metatype Service
>    Affects Versions: metatype-1.0.10
>            Reporter: David Humeniuk
>             Fix For: metatype-1.0.12
>
>
> An entry like the following will be treated as invalid and the default will change to null instead of an empty string:
> {code}
> <AD id="string.prop" cardinality="0" required="false" default="" type="String" description="Some string property"/>
> {code}
> MetaDataReader.readAD() method will first set the default value, then later check if the value is required:
> {code}
> ad.setDefaultValue( this.getOptionalAttribute( "default" ) );
> ad.setRequired( this.getOptionalAttribute( "required", true ) );
> {code}
> However, setDefaultValue method will check if the value is required (before it is known) in ADValidator.validateString():
> {code}
> if (ad.isRequired() && ((value == null) || (length == 0)))
> {
>     // Possible if the cardinality != 0 and input was something like
>     // "0,,1"...
>     return AD.VALIDATE_MISSING;
> }
> {code}
> The call to isRequired() will always be true at the time of the call.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)