mirror of https://github.com/apache/nifi.git
NIFI-549: Fixed NPE
This commit is contained in:
parent
0759660897
commit
ba96e43a8e
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue