changeset 9536:aa23225fd85f

Fixed exception in wq csv export (raising error_no_export_found) in cases when the calc range starts outside any gauge range
author mschaefer
date Tue, 16 Oct 2018 16:42:22 +0200
parents 3fa8551c3d1b
children bf6b63208f34
files artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Fri Oct 12 18:49:38 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Tue Oct 16 16:42:22 2018 +0200
@@ -607,10 +607,16 @@
 
         final List<Gauge> gauges = RiverUtils.getGauges(flys);
 
-        final Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
+        Gauge gauge = rangeAccess.getRiver().determineRefGauge(rangeAccess.getKmRange(), rangeAccess.isRange());
+
+        // REMARK gauge may be null when rangeAccess starts outside any gauge range
+        if (gauge == null)
+            gauge = rangeAccess.getRiver().determineRefGauge(wqkms.getKms(), rangeAccess.isRange());
 
         final String gaugeName = gauge.getName(); // RANDOMLY CHRASHES HERE, gauge is randomly null (especially on heavy load) - on production system as well
                                                   // (it seems to)
+                                                  // REMARK "randomly" crashes: see REMARK above
+
         String desc = "";
         final String notinrange = msg(CSV_NOT_IN_GAUGE_RANGE, DEFAULT_CSV_NOT_IN_GAUGE_RANGE);
 

http://dive4elements.wald.intevation.org