felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1595125 - /felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
Date Fri, 16 May 2014 07:01:46 GMT
Author: cziegeler
Date: Fri May 16 07:01:46 2014
New Revision: 1595125

URL: http://svn.apache.org/r1595125
Log:
FELIX-4489 : [Jetty] Ignore empty (string) entries in configuration arrays

Modified:
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java?rev=1595125&r1=1595124&r2=1595125&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
(original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
Fri May 16 07:01:46 2014
@@ -24,6 +24,7 @@ import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Properties;
 
 import org.apache.felix.http.base.internal.logger.SystemLogger;
@@ -518,20 +519,41 @@ public final class JettyConfig
         return value;
     }
 
+    /**
+     * Get the property value as a string array.
+     * Empty values are filtered out - if the resulting array is empty
+     * the default value is returned.
+     */
     private String[] getStringArrayProperty(String name, String[] defValue)
     {
         Object value = getProperty(name);
         if (value instanceof String)
         {
-            return new String[] { (String) value };
+            final String stringVal = ((String) value).trim();
+            if ( stringVal.length() > 0 )
+            {
+                return new String[] { stringVal };
+            }
         }
         else if (value instanceof String[])
         {
-            return (String[]) value;
+            final String[] stringArr = (String[]) value;
+            final List<String> list = new ArrayList<String>();
+            for(final String stringVal : stringArr)
+            {
+                if ( stringVal.trim().length() > 0 )
+                {
+                    list.add(stringVal.trim());
+                }
+            }
+            if ( list.size() > 0 )
+            {
+                return list.toArray(new String[list.size()]);
+            }
         }
         else if (value instanceof Collection)
         {
-            ArrayList<String> conv = new ArrayList<String>();
+            final ArrayList<String> conv = new ArrayList<String>();
             for (Iterator<?> vi = ((Collection<?>) value).iterator(); vi.hasNext();)
             {
                 Object object = vi.next();
@@ -540,12 +562,12 @@ public final class JettyConfig
                     conv.add(String.valueOf(object));
                 }
             }
-            return conv.toArray(new String[conv.size()]);
-        }
-        else
-        {
-            return defValue;
+            if ( conv.size() > 0 )
+            {
+                return conv.toArray(new String[conv.size()]);
+            }
         }
+        return defValue;
     }
 
     private int parseInt(String value, int dflt)



Mime
View raw message