Hello Ottomata, I'd like you to do a code review. Please visit
https://gerrit.wikimedia.org/r/190095 to review the following change. Change subject: Fix potential NPE stopping to abuse getters in Geocode data extraction ...................................................................... Fix potential NPE stopping to abuse getters in Geocode data extraction Bug: T89204 Change-Id: I73d00608b43571a40924817e5a1be374511e77bf --- M refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/Geocode.java 1 file changed, 25 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/analytics/refinery/source refs/changes/95/190095/1 diff --git a/refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/Geocode.java b/refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/Geocode.java index fe026cd..865b365 100644 --- a/refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/Geocode.java +++ b/refinery-core/src/main/java/org/wikimedia/analytics/refinery/core/Geocode.java @@ -163,14 +163,21 @@ return geoData; Continent continent = response.getContinent(); - if (continent != null && continent.getName() != null) - geoData.put(CONTINENT, continent.getName()); + if (continent != null) { + String name = continent.getName(); + if (name != null) { + geoData.put(CONTINENT, name); + } + } Country country = response.getCountry(); - if (country != null && country.getIsoCode() != null - && country.getName() != null) { - geoData.put(COUNTRY_CODE, country.getIsoCode()); - geoData.put(COUNTRY, country.getName()); + if (country != null) { + String name = country.getName(); + String isoCode = country.getIsoCode(); + if (name != null && isoCode != null) { + geoData.put(COUNTRY, name); + geoData.put(COUNTRY_CODE, isoCode); + } } List<Subdivision> subdivisions = response.getSubdivisions(); @@ -185,12 +192,20 @@ } City city = response.getCity(); - if (city != null && city.getName() != null) - geoData.put(CITY, city.getName()); + if (city != null) { + String name = city.getName(); + if (name != null) { + geoData.put(CITY, name); + } + } Postal postal = response.getPostal(); - if (postal != null && postal.getCode() != null) - geoData.put(POSTAL_CODE, postal.getCode()); + if (postal != null) { + String code = postal.getCode(); + if (code != null) { + geoData.put(POSTAL_CODE, code); + } + } Location location = response.getLocation(); if (location != null) { -- To view, visit https://gerrit.wikimedia.org/r/190095 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I73d00608b43571a40924817e5a1be374511e77bf Gerrit-PatchSet: 1 Gerrit-Project: analytics/refinery/source Gerrit-Branch: master Gerrit-Owner: QChris <christ...@quelltextlich.at> Gerrit-Reviewer: Ottomata <o...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits