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 191862d0a8747ac
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
     1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java	Sat May 16 23:55:11 2015 +0200
     1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/configuration/Properties.java	Sat May 16 23:58:06 2015 +0200
     1.3 @@ -23,13 +23,16 @@
     1.4  import java.util.Collections;
     1.5  
     1.6  /**
     1.7 - * <p>List of configurables.</p>
     1.8 + * <p>
     1.9 + * List of configurables.</p>
    1.10   *
    1.11 - * <p>Can be backed by defaults – if value for given name is nof found in this instance, we will
    1.12 + * <p>
    1.13 + * Can be backed by defaults – if value for given name is nof found in this instance, we will
    1.14   * look into defaults. Methods also accept defaultValue parameter – is used if property is nof found
    1.15   * even in default properties.</p>
    1.16   *
    1.17 - * <p>Typical use: </p>
    1.18 + * <p>
    1.19 + * Typical use: </p>
    1.20   * <ul>
    1.21   * <li>this instance – ad-hoc properties from CLI options</li>
    1.22   * <li>default properties – from config file</li>
    1.23 @@ -117,7 +120,10 @@
    1.24  			defaults.duplicateTo(javaProperties);
    1.25  		}
    1.26  		for (Property p : this) {
    1.27 -			javaProperties.setProperty(p.getName(), p.getValue());
    1.28 +			String value = p.getValue();
    1.29 +			if (value != null) {
    1.30 +				javaProperties.setProperty(p.getName(), value);
    1.31 +			}
    1.32  		}
    1.33  	}
    1.34  }