summaryrefslogtreecommitdiff
path: root/app/src/main/java/se
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2020-07-23 17:25:20 +0200
committercyBerta <cyberta@riseup.net>2020-07-23 17:25:20 +0200
commitb92177a2d26f0f96671c848d26c79b08dca13f71 (patch)
treec595e212fc8aa464bb14900b44c5ce50f5983e50 /app/src/main/java/se
parent0d2c7adabfe0b6863163051c53dc8c9c6852ec40 (diff)
fix potential nullpointer exception in geoipservice json parsing
Diffstat (limited to 'app/src/main/java/se')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java33
1 files changed, 16 insertions, 17 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
index e3932cb6..70d757d4 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/GatewaysManager.java
@@ -174,24 +174,23 @@ public class GatewaysManager {
}
private void parseGatewaysFromGeoIpServiceJson(Provider provider) {
- JSONObject geoIpJson = provider.getGeoIpJson();
- JSONArray gatewaylist = new JSONArray();
- try {
- gatewaylist = geoIpJson.getJSONArray(GATEWAYS);
- } catch (Exception e) {
- e.printStackTrace();
- }
+ try {
+ JSONObject geoIpJson = provider.getGeoIpJson();
+ JSONArray gatewaylist = geoIpJson.getJSONArray(GATEWAYS);
- for (int i = 0; i < gatewaylist.length(); i++) {
- try {
- String key = gatewaylist.getString(i);
- if (gateways.containsKey(key)) {
- presortedList.add(gateways.get(key));
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- }
+ for (int i = 0; i < gatewaylist.length(); i++) {
+ try {
+ String key = gatewaylist.getString(i);
+ if (gateways.containsKey(key)) {
+ presortedList.add(gateways.get(key));
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+ } catch (NullPointerException | JSONException npe) {
+ npe.printStackTrace();
+ }
}
private JSONObject secretsConfigurationFromCurrentProvider() {