diff flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java @ 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 9be8d7942284
children 92021091b03d
line wrap: on
line diff
--- 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