[PATCH] Fix exporter loops

Wald Commits scm-commit at wald.intevation.org
Mon Aug 25 20:12:16 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1408990331 -7200
# Node ID cda45ed151ed72c9a6ea423016e70d12736554a8
# Parent  05aca5659f32d81d1e65a8306a1a4a374e976068
Fix exporter loops

    The one loop did not increase the count. The other did not handle null gracefully.

diff -r 05aca5659f32 -r cda45ed151ed artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java	Mon Aug 25 20:03:35 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java	Mon Aug 25 20:12:11 2014 +0200
@@ -105,9 +105,13 @@
 
         TreeMap <String, TreeMap <Double, Double[]>> result_map =
             new TreeMap<String, TreeMap<Double, Double[]>>();
-        int i = 0;
-        for (String name: FRACTION_ORDER) {
-            for (Fraction fract: result.getFractionsByName(name)) {
+        for (int i = 0; i < FRACTION_ORDER.length; i++) {
+            String name = FRACTION_ORDER[i];
+            List<Fraction> fractions = result.getFractionsByName(name);
+            if (fractions == null) {
+                continue;
+            }
+            for (Fraction fract: fractions) {
                 String period = fract.getPeriod();
                 TreeMap<Double, Double[]> cur_map;
                 if (result_map.containsKey(period)) {


More information about the Dive4Elements-commits mailing list