changeset 6936:332d2dfa783f

issue1460: prevent NPEs when backstepping and changing Q values for WINFO projects.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 28 Aug 2013 11:22:40 +0200
parents 468d9ebda4ce
children 0a3dd5be6f81
files artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java	Tue Aug 27 19:14:12 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java	Wed Aug 28 11:22:40 2013 +0200
@@ -135,7 +135,8 @@
             CrossSectionLine csl = csls.get(0);
             // Find min-km of cross sections,
             // then set DATA_KM to min(DATA_KM, minCross).
-            double dataKm = Double.valueOf(getDataAsString(DATA_KM));
+            String dataKmValue = getDataAsString(DATA_KM);
+            double dataKm = (dataKmValue != null) ? Double.valueOf(dataKmValue) : Double.MIN_VALUE;
             if (dataKm < csl.getKm().doubleValue()) {
                 addStringData(DATA_KM, csl.getKm().toString());
             }
@@ -248,6 +249,10 @@
      */
     private double getParentKm() {
         String val = getDataAsString(PARENT_KM);
+        if (val == null) {
+            logger.warn("Empty data: " + PARENT_KM);
+            return 0;
+        }
         try {
             return Double.valueOf(val);
         }

http://dive4elements.wald.intevation.org