# HG changeset patch # User Christian Lins # Date 1350206487 -7200 # Node ID 989f6f0d1986443db841fd832678141cd231f4b1 # Parent 11c589d68f133dfb95e4bd3c3db439c21dcecf42 NPE fix when comparing Double with double diff -r 11c589d68f13 -r 989f6f0d1986 flys-client/ChangeLog --- a/flys-client/ChangeLog Sun Oct 14 10:15:50 2012 +0200 +++ b/flys-client/ChangeLog Sun Oct 14 11:21:27 2012 +0200 @@ -1,3 +1,8 @@ +2012-10-14 Christian Lins + + * flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java: + Fix for NPE that can occur when comparing Double with double. + 2012-10-14 Christian Lins * flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java: diff -r 11c589d68f13 -r 989f6f0d1986 flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java Sun Oct 14 10:15:50 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java Sun Oct 14 11:21:27 2012 +0200 @@ -1,9 +1,5 @@ package de.intevation.flys.client.client.ui; -import java.util.ArrayList; -import java.util.List; -import java.util.Iterator; - import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -20,13 +16,16 @@ import de.intevation.flys.client.client.FLYS; import de.intevation.flys.client.client.FLYSConstants; - import de.intevation.flys.client.shared.model.Data; import de.intevation.flys.client.shared.model.DataItem; import de.intevation.flys.client.shared.model.DataList; import de.intevation.flys.client.shared.model.GaugeInfo; import de.intevation.flys.client.shared.model.RiverInfo; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + public class GaugeTree extends ScrollPanel { @@ -276,12 +275,16 @@ } } else { - GWT.log("GaugeTree - openOnDistance gitem " + gitem.getStart() + " " + gitem.getEnd()); - if ((start >= gitem.getStart() && start <= gitem.getEnd()) || - (end >= gitem.getStart() && end <= gitem.getEnd()) || - (start <= gitem.getStart() && end >= gitem.getEnd())) { - setstate = true; - } + // as getStart()/getEnd() return Double objects, they can be null and + // can cause NPEs when comparing with double... strange... + if (gitem.getStart() != null && gitem.getEnd() != null) { + GWT.log("GaugeTree - openOnDistance gitem " + gitem.getStart() + " " + gitem.getEnd()); + if ((start >= gitem.getStart() && start <= gitem.getEnd()) || + (end >= gitem.getStart() && end <= gitem.getEnd()) || + (start <= gitem.getStart() && end >= gitem.getEnd())) { + setstate = true; + } + } } item.setState(setstate); } @@ -413,6 +416,7 @@ addClickHandler(this); } + @Override public void onClick(ClickEvent ev) { GWT.log("GaugeCurveAnchor - onClick " + gauge.getRiverName() + " " + gauge.getOfficialNumber());