[PATCH] (issue1763) Empty strings are most likely intended as missing values, so don't try to parse them (plus enhanced logging)

Wald Commits scm-commit at wald.intevation.org
Wed Apr 15 18:36:15 CEST 2015


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1429115771 -7200
# Node ID e1186c5ab169494322914ab8c7f91c634204b4c9
# Parent  3912da70736b0f83c7f94aba84e181d66753be67
(issue1763) Empty strings are most likely intended as missing values, so don't try to parse them (plus enhanced logging).

diff -r 3912da70736b -r e1186c5ab169 backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java	Wed Apr 15 17:30:27 2015 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightParser.java	Wed Apr 15 18:36:11 2015 +0200
@@ -409,40 +409,44 @@
         }
 
         Double height = null;
-        try {
-            height = new Double(nf.parse(values[1]).doubleValue());
-        }
-        catch (ParseException e) {
-            log.warn("BSP: unparseable height " + values[1]);
+        if (values[1].length() > 0) {
+            try {
+                height = new Double(nf.parse(values[1]).doubleValue());
+            }
+            catch (ParseException e) {
+                log.warn("BSP: unparseable height '" + values[1] + "'");
+            }
         }
 
         Double uncertainty = null;
-        if (values.length > 2) {
+        if (values.length > 2 && values[2].length() > 0) {
             try {
                 uncertainty = new Double(nf.parse(values[2]).doubleValue());
             }
             catch (ParseException e) {
-                log.warn("BSP: unparseable uncertainty value " + values[2]);
+                log.warn("BSP: unparseable uncertainty value '"
+                    + values[2] + "'");
             }
         }
 
         Double dataGap = null;
-        if (values.length > 3) {
+        if (values.length > 3 && values[3].length() > 0) {
             try {
                 dataGap = new Double(nf.parse(values[3]).doubleValue());
             }
             catch (ParseException e) {
-                log.warn("BSP: unparseable data gap " + values[3]);
+                log.warn("BSP: unparseable data gap '" + values[3] + "'");
             }
         }
 
         Double soundingWidth = null;
-        if (values.length > 4) {
+        if (values.length > 4 && values[4].length() > 0) {
             try {
                 soundingWidth = new Double(nf.parse(values[4]).doubleValue());
             }
             catch (ParseException e) {
-                log.warn("BSP: unparseable sounding width " + values[4]);
+                log.warn("BSP: unparseable sounding width '" +
+                    values[4] + "'");
             }
         }
 


More information about the Dive4Elements-commits mailing list