NIFI-549: Fixed NPE
Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/ba96e43a Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/ba96e43a Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/ba96e43a Branch: refs/heads/NIFI-292 Commit: ba96e43a8e0fa682e9c803228d292969ffd0c686 Parents: 0759660 Author: Mark Payne <[email protected]> Authored: Mon Apr 27 12:01:36 2015 -0400 Committer: Mark Payne <[email protected]> Committed: Mon Apr 27 12:01:36 2015 -0400 ---------------------------------------------------------------------- .../java/org/apache/nifi/processors/GeoEnrichIP.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/ba96e43a/nifi/nifi-nar-bundles/nifi-geo-bundle/nifi-geo-processors/src/main/java/org/apache/nifi/processors/GeoEnrichIP.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-geo-bundle/nifi-geo-processors/src/main/java/org/apache/nifi/processors/GeoEnrichIP.java b/nifi/nifi-nar-bundles/nifi-geo-bundle/nifi-geo-processors/src/main/java/org/apache/nifi/processors/GeoEnrichIP.java index be03243..1ecb221 100644 --- a/nifi/nifi-nar-bundles/nifi-geo-bundle/nifi-geo-processors/src/main/java/org/apache/nifi/processors/GeoEnrichIP.java +++ b/nifi/nifi-nar-bundles/nifi-geo-bundle/nifi-geo-processors/src/main/java/org/apache/nifi/processors/GeoEnrichIP.java @@ -189,8 +189,17 @@ public class GeoEnrichIP extends AbstractProcessor { final Map<String, String> attrs = new HashMap<>(); attrs.put(new StringBuilder(ipAttributeName).append(".geo.lookup.micros").toString(), String.valueOf(stopWatch.getDuration(TimeUnit.MICROSECONDS))); attrs.put(new StringBuilder(ipAttributeName).append(".geo.city").toString(), response.getCity().getName()); - attrs.put(new StringBuilder(ipAttributeName).append(".geo.latitude").toString(), response.getLocation().getLatitude().toString()); - attrs.put(new StringBuilder(ipAttributeName).append(".geo.longitude").toString(), response.getLocation().getLongitude().toString()); + + final Double latitude = response.getLocation().getLatitude(); + if ( latitude != null ) { + attrs.put(new StringBuilder(ipAttributeName).append(".geo.latitude").toString(), latitude.toString()); + } + + final Double longitude = response.getLocation().getLongitude(); + if ( longitude != null ) { + attrs.put(new StringBuilder(ipAttributeName).append(".geo.longitude").toString(), longitude.toString()); + } + int i = 0; for (final Subdivision subd : response.getSubdivisions()) { attrs.put(new StringBuilder(ipAttributeName).append(".geo.subdivision.").append(i).toString(), subd.getName());
