GeoIP: Fix NPE (thx parg)

This commit is contained in:
zzz
2018-12-17 11:24:27 +00:00
parent cae5dcd69c
commit 3867beb198

View File

@@ -174,7 +174,10 @@ public class GeoIP {
// returns upper case or "--" // returns upper case or "--"
String uc = ls.getCountry(ip).getCode(); String uc = ls.getCountry(ip).getCode();
if (!uc.equals(UNKNOWN_COUNTRY_CODE)) { 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); _IPToCountry.put(ipl, cached);
} else { } else {
_notFound.add(ipl); _notFound.add(ipl);
@@ -197,7 +200,10 @@ public class GeoIP {
// returns upper case or null // returns upper case or null
String uc = dbr.country(ipv4); String uc = dbr.country(ipv4);
if (uc != null) { 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); _IPToCountry.put(ipl, cached);
} else { } else {
_notFound.add(ipl); _notFound.add(ipl);
@@ -262,7 +268,10 @@ public class GeoIP {
// returns upper case or null // returns upper case or null
String uc = dbr.country(ipv6); String uc = dbr.country(ipv6);
if (uc != null) { 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); _IPToCountry.put(ipl, cached);
} else { } else {
_notFound.add(ipl); _notFound.add(ipl);