Mercurial > dive4elements > river
changeset 4129:989f6f0d1986
NPE fix when comparing Double with double
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sun, 14 Oct 2012 11:21:27 +0200 |
parents | 11c589d68f13 |
children | df8ac7ff6b1a |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java |
diffstat | 2 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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 <christian.lins@intevation.de> + + * 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 <christian.lins@intevation.de> * flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.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());