changeset 6746:d3c609581313 double-precision

Sediment Density parser: avoid NPE when no year is given
author Tom Gottfried <tom.gottfried@intevation.de>
date Fri, 02 Aug 2013 11:51:08 +0200
parents bd437771ea00
children 39f68dd8c188
files backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentDensityParser.java
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentDensityParser.java	Fri Aug 02 11:36:33 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/SedimentDensityParser.java	Fri Aug 02 11:51:08 2013 +0200
@@ -177,12 +177,14 @@
         }
 
         BigDecimal year = null;
-        try {
-            year = new BigDecimal(nf.parse(yearString).doubleValue());
-        }
-        catch (ParseException pe) {
-            log.warn("Unparseable year string");
-        }
+	if (yearString != null) {
+	    try {
+		year = new BigDecimal(nf.parse(yearString).doubleValue());
+	    }
+	    catch (ParseException pe) {
+		log.warn("Unparseable year string");
+	    }
+	}
 
         current.addValue(new ImportSedimentDensityValue(
             km,

http://dive4elements.wald.intevation.org