avoid NullPointerException (value = null) while duplicating to java.util.Properties v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 16 May 2015 23:58:06 +0200
branchv_0
changeset 191 862d0a8747ac
parent 190 3d4d378adc10
child 192 a32bfcbdee51
avoid NullPointerException (value = null) while duplicating to java.util.Properties
java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java
--- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java	Sat May 16 23:55:11 2015 +0200
+++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java	Sat May 16 23:58:06 2015 +0200
@@ -23,13 +23,16 @@
 import java.util.Collections;
 
 /**
- * <p>List of configurables.</p>
+ * <p>
+ * List of configurables.</p>
  *
- * <p>Can be backed by defaults – if value for given name is nof found in this instance, we will
+ * <p>
+ * Can be backed by defaults – if value for given name is nof found in this instance, we will
  * look into defaults. Methods also accept defaultValue parameter – is used if property is nof found
  * even in default properties.</p>
  *
- * <p>Typical use: </p>
+ * <p>
+ * Typical use: </p>
  * <ul>
  * <li>this instance – ad-hoc properties from CLI options</li>
  * <li>default properties – from config file</li>
@@ -117,7 +120,10 @@
 			defaults.duplicateTo(javaProperties);
 		}
 		for (Property p : this) {
-			javaProperties.setProperty(p.getName(), p.getValue());
+			String value = p.getValue();
+			if (value != null) {
+				javaProperties.setProperty(p.getName(), value);
+			}
 		}
 	}
 }