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 be03243802..1ecb221daa 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 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());