changeset 4153:3245bb4d600b

Avoid possible NullPointerException in openOnLocation method.
author Björn Ricks <bjoern.ricks@intevation.de>
date Tue, 16 Oct 2012 13:06:46 +0200
parents 5ff3b2f5fb1c
children 92021091b03d
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java
diffstat 2 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Oct 16 12:42:52 2012 +0200
+++ b/flys-client/ChangeLog	Tue Oct 16 13:06:46 2012 +0200
@@ -1,3 +1,8 @@
+2012-10-16	Björn Ricks	<bjoern.ricks@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java:
+	  Avoid possible NullPointerException in openOnLocation method.
+
 2012-10-16	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java	Tue Oct 16 12:42:52 2012 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java	Tue Oct 16 13:06:46 2012 +0200
@@ -291,6 +291,9 @@
         }
     }
 
+    /**
+     * Open Gauge entry if a location fits to the gauge
+     */
     public void openOnLocations(List<Double> locations) {
         GWT.log("GaugeTree - openOnLocations " + locations + " " +
                 tree.getItemCount());
@@ -308,11 +311,18 @@
                     if (locations == null) {
                         continue;
                     }
-                    if (location >= gitem.getStart() &&
-                            location <= gitem.getEnd()) {
+
+                    Double start = gitem.getStart();
+                    Double end   = gitem.getEnd();
+                    if (start == null || end == null) {
+                        // should not occur but avoid NullPointerException
+                        continue;
+                    }
+
+                    if (location >= start && location <= end) {
                         isset = true;
                         break;
-                            }
+                    }
                 }
                 item.setState(isset);
             }

http://dive4elements.wald.intevation.org