You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by David Jencks <da...@yahoo.com.INVALID> on 2014/08/06 03:35:04 UTC
Why is config admin checking for empty collections in Configuration values?
While writing a test I discovered that config admin doesn't like empty collections or collections with empty values as configuration values. After searching the 5.0 config admin spec for a while I can't find any support for these restrictions, and they are not applied to arrays. What is the justification for these checks?
Here's the code I'm asking about (CaseInsensitiveDictionary lines 309ff)
if ( collection.isEmpty() )
{
throw new IllegalArgumentException( "Collection must not be empty" );
}
// ensure all elements have the same type and to internal list
Collection internalValue = new ArrayList( collection.size() );
type = null;
for ( Iterator ci = collection.iterator(); ci.hasNext(); )
{
Object el = ci.next();
if ( el == null )
{
throw new IllegalArgumentException( "Collection must not contain null elements" );
}
thanks
david jencks
Re: Why is config admin checking for empty collections in
Configuration values?
Posted by Felix Meschberger <fm...@adobe.com>.
Hi David
Hmm, good question. It has always been there - ever since it was first imported into the Felix project as part of FELIX-11.
While an empty collection does not make that much sense, I think the check doesn't either. On the other hand: If empty collections are allowed, then it must be made sure the ConfigurationHandler serializer can also read and write such empty collections.
Regards
Felix
Am 06.08.2014 um 03:35 schrieb David Jencks <da...@yahoo.com.INVALID>:
> While writing a test I discovered that config admin doesn't like empty collections or collections with empty values as configuration values. After searching the 5.0 config admin spec for a while I can't find any support for these restrictions, and they are not applied to arrays. What is the justification for these checks?
>
> Here's the code I'm asking about (CaseInsensitiveDictionary lines 309ff)
>
> if ( collection.isEmpty() )
> {
> throw new IllegalArgumentException( "Collection must not be empty" );
> }
>
> // ensure all elements have the same type and to internal list
> Collection internalValue = new ArrayList( collection.size() );
> type = null;
> for ( Iterator ci = collection.iterator(); ci.hasNext(); )
> {
> Object el = ci.next();
> if ( el == null )
> {
> throw new IllegalArgumentException( "Collection must not contain null elements" );
> }
>
>
> thanks
> david jencks
Re: Why is config admin checking for empty collections in
Configuration values?
Posted by Carsten Ziegeler <cz...@apache.org>.
I didn't find anything either, my first assumption was that there is a test
for this in the CT which doesn't seem to be the case either. So I guess
this check can be removed.
Carsten
2014-08-06 3:35 GMT+02:00 David Jencks <da...@yahoo.com.invalid>:
> While writing a test I discovered that config admin doesn't like empty
> collections or collections with empty values as configuration values.
> After searching the 5.0 config admin spec for a while I can't find any
> support for these restrictions, and they are not applied to arrays. What
> is the justification for these checks?
>
> Here's the code I'm asking about (CaseInsensitiveDictionary lines 309ff)
>
> if ( collection.isEmpty() )
> {
> throw new IllegalArgumentException( "Collection must not
> be empty" );
> }
>
> // ensure all elements have the same type and to internal list
> Collection internalValue = new ArrayList( collection.size() );
> type = null;
> for ( Iterator ci = collection.iterator(); ci.hasNext(); )
> {
> Object el = ci.next();
> if ( el == null )
> {
> throw new IllegalArgumentException( "Collection must
> not contain null elements" );
> }
>
>
> thanks
> david jencks
--
Carsten Ziegeler
Adobe Research Switzerland
cziegeler@apache.org