[
https://issues.apache.org/jira/browse/FELIX-6009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16731574#comment-16731574
]
Andreas Lemmer commented on FELIX-6009:
---------------------------------------
Your citation doesn't say anything about the case where the cardinality is
zero, it is applicable only to cardinality != 0.
With the current implementation, there is no way to find out if an empty string
default is defined or no default is defined.
I'm referring to the following paragraphs:
R7, § 105.4, last element:
* A default value (String[]). The return depends on the following cases:
** not specified - Return null if this attribute is not specified.
** *cardinality = 0 - Return an array with one element.*
** otherwise - Return an array with less or equal than the absolute value of
cardinality, possibly empty if the value is an empty string.
R7, § 105.14.2.14, public String[] getDefaultValue()
Return a default for this attribute. The object must be of the appropriate type
as defined by the cardinality and getType(). The return type is a list of
String objects that can be converted to the appropriate type. The cardinality
of the return array must follow the absolute cardinality of this type. *For
example, if the cardinality = 0, the array must contain 1 element.* If the
cardinality is 1, it must contain 0 or 1 elements. If it is -5, it must contain
from 0 to max 5 elements. Note that the special case of a 0 cardinality,
meaning a single value, does not allow arrays or lists of 0 elements.
Returns *Return a default value or null if no default exists.*
> Metatype AD empty String default value
> --------------------------------------
>
> Key: FELIX-6009
> URL: https://issues.apache.org/jira/browse/FELIX-6009
> Project: Felix
> Issue Type: Bug
> Components: Metatype Service
> Affects Versions: metatype-1.2.2
> Reporter: Andreas Lemmer
> Priority: Critical
> Fix For: metatype-1.2.4
>
>
> I have an AD with a default value which is an empty string, like
> {{<AD id="server" type="String" default=""/>}}
> According to the OSGi Spec, the method AttributeDefinition.defaultValue() in
> this case must return an array with one element (which should be the empty
> string), because the cardinality is 0 (implicit) and the default is defined.
> However, the Felix Metatype Service implementation returns null for
> defaultValue().
> In my use case, this breaks everything, because a null value indicates a
> configuration error (default not given, although mandatory) whereas an empty
> string is perfectly fine.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)