From 87826ce5c276489d74b37618b9d534b32e446eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Mon, 10 Mar 2014 21:36:13 +0100 Subject: ConcurrentModification at switching provider fixed This fixes bug 5237. --- src/se/leap/bitmaskclient/EIP.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/se/leap/bitmaskclient/EIP.java') diff --git a/src/se/leap/bitmaskclient/EIP.java b/src/se/leap/bitmaskclient/EIP.java index 169178d1..b3b2c95d 100644 --- a/src/se/leap/bitmaskclient/EIP.java +++ b/src/se/leap/bitmaskclient/EIP.java @@ -280,9 +280,9 @@ public final class EIP extends IntentService { if(parsedEipSerial == 0) { // Delete all vpn profiles ProfileManager vpl = ProfileManager.getInstance(context); - Collection profiles = vpl.getProfiles(); - for (VpnProfile profile : profiles){ - vpl.removeProfile(context, profile); + VpnProfile[] profiles = (VpnProfile[]) vpl.getProfiles().toArray(new VpnProfile[vpl.getProfiles().size()]); + for (int current_profile = 0; current_profile < profiles.length; current_profile++){ + vpl.removeProfile(context, profiles[current_profile]); } } if (eipDefinition.optInt("serial") > parsedEipSerial) -- cgit v1.2.3 From 1df967637d432bccc405f0a2e7ce46dc236cffff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Tue, 11 Mar 2014 19:48:22 +0100 Subject: Locations in eip-service can be empty. --- src/se/leap/bitmaskclient/EIP.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/se/leap/bitmaskclient/EIP.java') diff --git a/src/se/leap/bitmaskclient/EIP.java b/src/se/leap/bitmaskclient/EIP.java index b3b2c95d..e773e3b9 100644 --- a/src/se/leap/bitmaskclient/EIP.java +++ b/src/se/leap/bitmaskclient/EIP.java @@ -332,14 +332,15 @@ public final class EIP extends IntentService { } } - String closestLocation = offsets.firstEntry().getValue().iterator().next(); + + String closestLocation = offsets.isEmpty() ? "" : offsets.firstEntry().getValue().iterator().next(); JSONArray gateways = null; String chosenHost = null; try { gateways = eipDefinition.getJSONArray("gateways"); for (int i = 0; i < gateways.length(); i++) { JSONObject gw = gateways.getJSONObject(i); - if ( gw.getString("location").equalsIgnoreCase(closestLocation) ){ + if ( gw.getString("location").equalsIgnoreCase(closestLocation) || closestLocation.isEmpty()){ chosenHost = gw.getString("host"); break; } -- cgit v1.2.3