[PATCH 1 of 3] issue1755 Prevent out of bounds access when there is no data

Wald Commits scm-commit at wald.intevation.org
Mon Apr 13 11:27:35 CEST 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1428915780 -7200
# Node ID 5102733c4567d24126be49225476682ddbee4df3
# Parent  1f878c82262f249d1400b2d1f14e88db023c652f
issue1755 Prevent out of bounds access when there is no data

    If there is no data it will default to the complete river.
    In the following overview you can then see that there is no
    data. Better then a "Error changing state".

diff -r 1f878c82262f -r 5102733c4567 artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityDistanceSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityDistanceSelect.java	Fri Apr 10 17:47:00 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/BedQualityDistanceSelect.java	Mon Apr 13 11:03:00 2015 +0200
@@ -65,6 +65,10 @@
         }
 
         KMIndex<List<Date>> entries = overview.filter(BedOverview.ACCEPT);
+        if (entries.size() == 0) {
+            log.warn("No data found for river '" + access.getRiverName() + "'");
+            return ele;
+        }
         entries.sort();
 
         if (data.getName().equals("ld_from")) {


More information about the Dive4Elements-commits mailing list