[PATCH] issue1460: prevent NPEs when backstepping and changing Q values for WINFO

Wald Commits scm-commit at wald.intevation.org
Wed Aug 28 11:12:22 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1377681760 -7200
# Node ID 332d2dfa783f43042c939a88f823dd72d428b54c
# Parent  468d9ebda4cecf6771cea18b5ddeb1553fd79341
issue1460: prevent NPEs when backstepping and changing Q values for WINFO
projects.

diff -r 468d9ebda4ce -r 332d2dfa783f artifacts/src/main/java/org/dive4elements/river/artifacts/CrossSectionArtifact.java
--- 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);
         }


More information about the Dive4elements-commits mailing list