FELIX-662 Not calling toType if the property is null and catching NumberFormatException
if the target type is numeric but the property value cannot be parsed/converted
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@700063 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
index c5378f2..ed82607 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
@@ -729,7 +729,17 @@
{
// scalar of non-string
String prop = request.getParameter( propName );
- props.put( propName, this.toType( ad.getType(), prop ) );
+ if ( prop != null )
+ {
+ try
+ {
+ props.put( propName, this.toType( ad.getType(), prop ) );
+ }
+ catch ( NumberFormatException nfe )
+ {
+ // don't care
+ }
+ }
}
else
{
@@ -741,7 +751,14 @@
{
for ( int i = 0; i < properties.length; i++ )
{
- vec.add( this.toType( ad.getType(), properties[i] ) );
+ try
+ {
+ vec.add( this.toType( ad.getType(), properties[i] ) );
+ }
+ catch ( NumberFormatException nfe )
+ {
+ // don't care
+ }
}
}
@@ -785,6 +802,10 @@
}
+ /**
+ * @throws NumberFormatException If the value cannot be converted to
+ * a number and type indicates a numeric type
+ */
private Object toType( int type, String value )
{
switch ( type )