changeset 2794:3c26e16ae6c2

Fix or workaround flys/issue632, avoid NPE. flys-backend/trunk@4112 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 02 Mar 2012 12:15:40 +0000
parents 67f362883fe4
children c41bb1293acb
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/model/Wst.java
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Tue Feb 14 16:37:19 2012 +0000
+++ b/flys-backend/ChangeLog	Fri Mar 02 12:15:40 2012 +0000
@@ -1,3 +1,10 @@
+2012-03-02  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	Fix or workaround flys/issue632 .
+
+	* src/main/java/de/intevation/flys/model/Wst.java: Avoid NPE when
+	  trying to get min/max q values.
+
 2012-02-14	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/model/DischargeTable.java:
--- a/flys-backend/src/main/java/de/intevation/flys/model/Wst.java	Tue Feb 14 16:37:19 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Wst.java	Fri Mar 02 12:15:40 2012 +0000
@@ -42,7 +42,7 @@
 
     public static final String SQL_SELECT_MINMAX =
         "select min(q) as minQ, max(q) as maxQ from wst_q_values " +
-        "where wst_id = :wst and  not (a > :km or b < :km)";
+        "where wst_id = :wst and not (a > :km or b < :km)";
 
     public Wst() {
     }
@@ -197,12 +197,18 @@
 
         List<Object[]> minmaxQ = sqlQuery.list();
 
+
         if (minmaxQ.isEmpty()) {
             return null;
         }
 
         Object[] mm = minmaxQ.get(0);
 
+        if (mm[0] == null || mm[1] == null) {
+            logger.warning ("No min/max Q for km " + km + " found.");
+            return null;
+        }
+
         return new double[] { (Double) mm[0], (Double) mm[1] };
     }
 }

http://dive4elements.wald.intevation.org