You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2017/11/15 05:02:51 UTC
svn commit: r1815288 - in /felix/trunk/osgi-r7/configadmin: changelog.txt
src/main/java/org/apache/felix/cm/impl/CaseInsensitiveDictionary.java
Author: cziegeler
Date: Wed Nov 15 05:02:50 2017
New Revision: 1815288
URL: http://svn.apache.org/viewvc?rev=1815288&view=rev
Log:
FELIX-5745 : Empty collections should be allowed as property value
Modified:
felix/trunk/osgi-r7/configadmin/changelog.txt
felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/CaseInsensitiveDictionary.java
Modified: felix/trunk/osgi-r7/configadmin/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configadmin/changelog.txt?rev=1815288&r1=1815287&r2=1815288&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configadmin/changelog.txt (original)
+++ felix/trunk/osgi-r7/configadmin/changelog.txt Wed Nov 15 05:02:50 2017
@@ -9,6 +9,8 @@ Changes in 1.9.0
* [FELIX-5293] - Improved ConfigurationPlugin Support (OSGi R7)
* [FELIX-5468] - Refactor persistence handling
* [FELIX-5695] - Use Java 7 as base version
+** Bug
+ * [FELIX-5745] - Empty collections should be allowed as property value
Changes from 1.8.14 to 1.8.16
Modified: felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/CaseInsensitiveDictionary.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/CaseInsensitiveDictionary.java?rev=1815288&r1=1815287&r2=1815288&view=diff
==============================================================================
--- felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/CaseInsensitiveDictionary.java (original)
+++ felix/trunk/osgi-r7/configadmin/src/main/java/org/apache/felix/cm/impl/CaseInsensitiveDictionary.java Wed Nov 15 05:02:50 2017
@@ -51,7 +51,7 @@ public class CaseInsensitiveDictionary e
public CaseInsensitiveDictionary()
{
- internalMap = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
+ internalMap = new TreeMap<>( CASE_INSENSITIVE_ORDER );
}
@@ -59,11 +59,11 @@ public class CaseInsensitiveDictionary e
{
if ( props instanceof CaseInsensitiveDictionary)
{
- internalMap = new TreeMap<String, Object>( ((CaseInsensitiveDictionary) props).internalMap );
+ internalMap = new TreeMap<>( ((CaseInsensitiveDictionary) props).internalMap );
}
else if ( props != null )
{
- internalMap = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
+ internalMap = new TreeMap<>( CASE_INSENSITIVE_ORDER );
Enumeration keys = props.keys();
while ( keys.hasMoreElements() )
{
@@ -88,7 +88,7 @@ public class CaseInsensitiveDictionary e
}
else
{
- internalMap = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
+ internalMap = new TreeMap<>( CASE_INSENSITIVE_ORDER );
}
}
@@ -97,7 +97,7 @@ public class CaseInsensitiveDictionary e
{
if ( deepCopy )
{
- internalMap = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
+ internalMap = new TreeMap<>( CASE_INSENSITIVE_ORDER );
for( Map.Entry<String, Object> entry : props.internalMap.entrySet() )
{
Object value = entry.getValue();
@@ -117,14 +117,14 @@ public class CaseInsensitiveDictionary e
// Vector. And even though we accept Collection nowadays
// there might be clients out there still written against
// R4 and R4.1 spec expecting Vector
- value = new Vector<Object>( ( Collection ) value );
+ value = new Vector<>( ( Collection ) value );
}
internalMap.put( entry.getKey(), value );
}
}
else
{
- internalMap = new TreeMap<String, Object>( props.internalMap );
+ internalMap = new TreeMap<>( props.internalMap );
}
}
@@ -273,7 +273,7 @@ public class CaseInsensitiveDictionary e
}
- private static final Set<Class> KNOWN = new HashSet<Class>(Arrays.<Class>asList(
+ private static final Set<Class> KNOWN = new HashSet<>(Arrays.<Class>asList(
String.class, Integer.class, Long.class, Float.class,
Double.class, Byte.class, Short.class, Character.class,
Boolean.class));
@@ -312,29 +312,31 @@ public class CaseInsensitiveDictionary e
Collection collection = ( Collection ) value;
if ( collection.isEmpty() )
{
- throw new IllegalArgumentException( "Collection must not be empty" );
+ value = Collections.EMPTY_LIST;
}
-
- // ensure all elements have the same type and to internal list
- Collection<Object> internalValue = new ArrayList<Object>( collection.size() );
- type = null;
- for ( Object el : collection )
+ else
{
- if ( el == null )
- {
- throw new IllegalArgumentException( "Collection must not contain null elements" );
- }
- if ( type == null )
+ // ensure all elements have the same type and to internal list
+ Collection<Object> internalValue = new ArrayList<>( collection.size() );
+ type = null;
+ for ( Object el : collection )
{
- type = el.getClass();
+ if ( el == null )
+ {
+ throw new IllegalArgumentException( "Collection must not contain null elements" );
+ }
+ if ( type == null )
+ {
+ type = el.getClass();
+ }
+ else if ( type != el.getClass() )
+ {
+ throw new IllegalArgumentException( "Collection element types must not be mixed" );
+ }
+ internalValue.add( el );
}
- else if ( type != el.getClass() )
- {
- throw new IllegalArgumentException( "Collection element types must not be mixed" );
- }
- internalValue.add( el );
+ value = internalValue;
}
- value = internalValue;
}
else
{
@@ -495,6 +497,7 @@ public class CaseInsensitiveDictionary e
private static class CaseInsensitiveComparator implements Comparator<String>
{
+ @Override
public int compare(String s1, String s2)
{
int n1 = s1.length();