I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 3867beb1 authored by zzz's avatar zzz
Browse files

GeoIP: Fix NPE (thx parg)

parent cae5dcd6
No related branches found
No related tags found
No related merge requests found
...@@ -174,7 +174,10 @@ public class GeoIP { ...@@ -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 { ...@@ -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 { ...@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment