From 328ea1b130a3b6064280f6bdc37b6f5f00e881ea Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Fri, 12 Aug 2022 14:41:22 +0200 Subject: Mark all methods in profile manager synchronized to avoid race conditions --- main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java b/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java index b46a8f10..9f5c3ab5 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java +++ b/main/src/main/java/de/blinkt/openvpn/core/ProfileManager.java @@ -250,7 +250,7 @@ public class ProfileManager { editor.apply(); } - public void addProfile(VpnProfile profile) { + public synchronized void addProfile(VpnProfile profile) { profiles.put(profile.getUUID().toString(), profile); } @@ -259,7 +259,7 @@ public class ProfileManager { * profiles * @param context */ - public void refreshVPNList(Context context) + public synchronized void refreshVPNList(Context context) { SharedPreferences listpref = Preferences.getSharedPreferencesMulti(PREFS_NAME, context); Set vlist = listpref.getStringSet("vpnlist", null); @@ -283,7 +283,7 @@ public class ProfileManager { } } - private void loadVPNList(Context context) { + private synchronized void loadVPNList(Context context) { profiles = new HashMap<>(); SharedPreferences listpref = Preferences.getSharedPreferencesMulti(PREFS_NAME, context); Set vlist = listpref.getStringSet("vpnlist", null); @@ -298,7 +298,7 @@ public class ProfileManager { } } - private void loadVpnEntry(Context context, String vpnentry) { + private synchronized void loadVpnEntry(Context context, String vpnentry) { ObjectInputStream vpnfile = null; try { FileInputStream vpInput; @@ -339,7 +339,7 @@ public class ProfileManager { } } - public void removeProfile(Context context, VpnProfile profile) { + public synchronized void removeProfile(Context context, VpnProfile profile) { String vpnentry = profile.getUUID().toString(); profiles.remove(vpnentry); saveProfileList(context); -- cgit v1.2.3