# HG changeset patch # User "Tom Gottfried " # Date 1411744971 -7200 # Node ID f5461750e5c7ec97e044aa8bb65d5183b3a9859f # Parent b9fa8124583cf0558269f07a6db02573a90a599f Avoid NPE if river is not accessible. diff -r b9fa8124583c -r f5461750e5c7 artifacts/src/main/java/org/dive4elements/river/exports/injector/PNPInjector.java --- 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);