From 3867beb198ea50f7423268d796e8987f955bf5ff Mon Sep 17 00:00:00 2001 From: zzz Date: Mon, 17 Dec 2018 11:24:27 +0000 Subject: [PATCH] GeoIP: Fix NPE (thx parg) --- .../java/src/net/i2p/router/transport/GeoIP.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/GeoIP.java b/router/java/src/net/i2p/router/transport/GeoIP.java index 086c071ee..789fbe382 100644 --- a/router/java/src/net/i2p/router/transport/GeoIP.java +++ b/router/java/src/net/i2p/router/transport/GeoIP.java @@ -174,7 +174,10 @@ public class GeoIP { // returns upper case or "--" String uc = ls.getCountry(ip).getCode(); if (!uc.equals(UNKNOWN_COUNTRY_CODE)) { - String cached = _codeCache.get(uc.toLowerCase(Locale.US)); + String lc = uc.toLowerCase(Locale.US); + String cached = _codeCache.get(lc); + if (cached == null) + cached = lc; _IPToCountry.put(ipl, cached); } else { _notFound.add(ipl); @@ -197,7 +200,10 @@ public class GeoIP { // returns upper case or null String uc = dbr.country(ipv4); if (uc != null) { - String cached = _codeCache.get(uc.toLowerCase(Locale.US)); + String lc = uc.toLowerCase(Locale.US); + String cached = _codeCache.get(lc); + if (cached == null) + cached = lc; _IPToCountry.put(ipl, cached); } else { _notFound.add(ipl); @@ -262,7 +268,10 @@ public class GeoIP { // returns upper case or null String uc = dbr.country(ipv6); if (uc != null) { - String cached = _codeCache.get(uc.toLowerCase(Locale.US)); + String lc = uc.toLowerCase(Locale.US); + String cached = _codeCache.get(lc); + if (cached == null) + cached = lc; _IPToCountry.put(ipl, cached); } else { _notFound.add(ipl);