From d45b7c7b6d66b448366538ad67de31a644f49d16 Mon Sep 17 00:00:00 2001 From: Tom Hennen Date: Tue, 28 Jul 2015 17:26:02 -0400 Subject: [PATCH] * fix ConcurrentModificationException in Gpodder * removed 'About' tests (they take too long) --- .../test/antennapod/ui/PreferencesTest.java | 26 ------------------- .../core/preferences/GpodnetPreferences.java | 19 +++++++++++--- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java index 99954bf77..a6af6c544 100644 --- a/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java +++ b/app/src/androidTest/java/de/test/antennapod/ui/PreferencesTest.java @@ -426,30 +426,4 @@ public class PreferencesTest extends ActivityInstrumentationTestCase2 lines = IOUtils.readLines(input); - input.close(); - for(String line : lines) { - if(line.contains("(View)")) { - numViews++; - } else if(line.contains("(Link)")) { - numLinks++; - } - } - for(int i=0; i < numViews; i++) { - solo.clickOnText(solo.getString(R.string.about_pref)); - solo.clickOnText("(View)", i); - solo.goBack(); - } - for(int i=0; i < numLinks; i++) { - solo.clickOnText(solo.getString(R.string.about_pref)); - solo.clickOnText("(Link)", i); - solo.goBack(); - } - } - } diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java index c3c6ce8c5..1401d5f39 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java @@ -8,7 +8,6 @@ import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -217,26 +216,36 @@ public class GpodnetPreferences { public static void removeRemovedFeeds(Collection removed) { ensurePreferencesLoaded(); + feedListLock.lock(); removedFeeds.removeAll(removed); writePreference(PREF_SYNC_REMOVED, removedFeeds); + feedListLock.unlock(); } - public static synchronized void enqueueEpisodeAction(GpodnetEpisodeAction action) { + public static void enqueueEpisodeAction(GpodnetEpisodeAction action) { ensurePreferencesLoaded(); + feedListLock.lock(); queuedEpisodeActions.add(action); writePreference(PREF_SYNC_EPISODE_ACTIONS, writeEpisodeActionsToString(queuedEpisodeActions)); + feedListLock.unlock(); GpodnetSyncService.sendSyncActionsIntent(ClientConfig.applicationCallbacks.getApplicationInstance()); } public static List getQueuedEpisodeActions() { ensurePreferencesLoaded(); - return Collections.unmodifiableList(queuedEpisodeActions); + List copy = new ArrayList(); + feedListLock.lock(); + copy.addAll(queuedEpisodeActions); + feedListLock.unlock(); + return copy; } - public static synchronized void removeQueuedEpisodeActions(Collection queued) { + public static void removeQueuedEpisodeActions(Collection queued) { ensurePreferencesLoaded(); + feedListLock.lock(); queuedEpisodeActions.removeAll(queued); writePreference(PREF_SYNC_EPISODE_ACTIONS, writeEpisodeActionsToString(queuedEpisodeActions)); + feedListLock.unlock(); } /** @@ -252,12 +261,14 @@ public class GpodnetPreferences { setUsername(null); setPassword(null); setDeviceID(null); + feedListLock.lock(); addedFeeds.clear(); writePreference(PREF_SYNC_ADDED, addedFeeds); removedFeeds.clear(); writePreference(PREF_SYNC_REMOVED, removedFeeds); queuedEpisodeActions.clear(); writePreference(PREF_SYNC_EPISODE_ACTIONS, writeEpisodeActionsToString(queuedEpisodeActions)); + feedListLock.unlock(); setLastSubscriptionSyncTimestamp(0); }