Mercurial > dive4elements > river
changeset 8337:f5461750e5c7
Avoid NPE if river is not accessible.
author | "Tom Gottfried <tom@intevation.de>" |
---|---|
date | Fri, 26 Sep 2014 17:22:51 +0200 |
parents | b9fa8124583c |
children | ac7cb15e1946 |
files | artifacts/src/main/java/org/dive4elements/river/exports/injector/PNPInjector.java |
diffstat | 1 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/injector/PNPInjector.java Fri Sep 26 14:22:37 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/injector/PNPInjector.java Fri Sep 26 17:22:51 2014 +0200 @@ -6,6 +6,7 @@ import org.dive4elements.artifacts.ContextInjector; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.RiverAccess; +import org.dive4elements.river.model.River; import org.dive4elements.river.model.Gauge; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -37,14 +38,20 @@ return; } - RiverAccess access = new RiverAccess((D4EArtifact)artifact); Double km = Double.valueOf(currentKm.toString()); if (Double.isNaN(km) || Double.isInfinite(km)) { log.debug("current km is NAN or infinte. not injecting pnp."); return; } + + River river = new RiverAccess((D4EArtifact)artifact).getRiver(); + if (river == null) { + log.error("River not accessible from artifact. Not injecting PNP"); + return; + } + Gauge gauge = - access.getRiver().determineGaugeByStation( + river.determineGaugeByStation( km - GAUGE_EPSILON, km + GAUGE_EPSILON);